use of org.evosuite.continuous.project.ProjectStaticData.ClassInfo in project evosuite by EvoSuite.
the class ProjectGraphTest method testClassTypes.
@Test
public void testClassTypes() {
ProjectStaticData data = new ProjectStaticData();
data.addNewClass(new ClassInfo(A.class, 1, true));
data.addNewClass(new ClassInfo(B.class, 1, true));
data.addNewClass(new ClassInfo(C.class, 0, false));
data.addNewClass(new ClassInfo(D.class, 0, false));
data.addNewClass(new ClassInfo(E.class, 1, true));
data.addNewClass(new ClassInfo(F.class, 0, false));
data.addNewClass(new ClassInfo(G.class, 1, true));
ProjectGraph graph = data.getProjectGraph();
Assert.assertTrue(graph.isConcrete(A.class.getName()));
Assert.assertTrue(graph.isConcrete(B.class.getName()));
Assert.assertTrue(graph.isInterface(C.class.getName()));
Assert.assertTrue(graph.isInterface(D.class.getName()));
Assert.assertTrue(graph.isAbstract(E.class.getName()));
Assert.assertTrue(graph.isInterface(F.class.getName()));
Assert.assertTrue(graph.isAbstract(G.class.getName()));
}
use of org.evosuite.continuous.project.ProjectStaticData.ClassInfo in project evosuite by EvoSuite.
the class ProjectAnalyzerIntTest method testBranches.
@Test
public void testBranches() {
String[] cuts = new String[] { Simple.class.getName(), Trivial.class.getName() };
ProjectAnalyzer pa = new ProjectAnalyzer(cuts);
ProjectStaticData data = pa.analyze();
Assert.assertEquals(2, data.getTotalNumberOfClasses());
ClassInfo simple = data.getClassInfo(Simple.class.getName());
Assert.assertNotNull(simple);
Assert.assertEquals(2, simple.numberOfBranches);
ClassInfo trivial = data.getClassInfo(Trivial.class.getName());
Assert.assertNotNull(trivial);
Assert.assertEquals(1, trivial.numberOfBranches);
}
use of org.evosuite.continuous.project.ProjectStaticData.ClassInfo in project evosuite by EvoSuite.
the class JobScheduler method createNewSchedule.
/**
* Return new schedule, or <code>null</code> if scheduling is finished
* @return
*/
public List<JobDefinition> createNewSchedule() {
if (!canExecuteMore()) {
logger.info("Cannot schedule more jobs");
return null;
}
logger.info("Creating new schedule with " + currentSchedule.getClass().getSimpleName());
// update some extra information of each Class-Under-Test
List<JobDefinition> jobs = currentSchedule.createNewSchedule();
for (JobDefinition job : jobs) {
ClassInfo classInfo = this.projectData.getClassInfo(job.cut);
classInfo.setTimeBudgetInSeconds(job.seconds);
classInfo.setMemoryInMB(job.memoryInMB);
}
return jobs;
}
use of org.evosuite.continuous.project.ProjectStaticData.ClassInfo in project evosuite by EvoSuite.
the class BudgetSchedule method createScheduleOnce.
@Override
protected List<JobDefinition> createScheduleOnce() {
ProjectStaticData data = scheduler.getProjectData();
if (data.getTotalNumberOfBranches() == 0) {
return new SimpleSchedule(scheduler).createScheduleOnce();
}
int maximumBudgetPerCore = 60 * scheduler.getConfiguration().timeInMinutes;
/*
* the total budget we need to choose how to allocate
*/
int totalBudget = maximumBudgetPerCore * scheduler.getConfiguration().getNumberOfUsableCores();
/*
* a part of the budget is fixed, as each CUT needs a minimum
* of it.
*/
int minTime = 60 * scheduler.getConfiguration().minMinutesPerJob * data.getTotalNumberOfTestableCUTs();
/*
* this is what left from the minimum allocation, and that now we can
* choose how best to allocate
*/
int extraTime = totalBudget - minTime;
/*
* check how much time we can give extra for each branch in a CUT
*/
double timePerBranch = (double) extraTime / (double) data.getTotalNumberOfBranches();
int totalLeftOver = 0;
List<JobDefinition> jobs = new LinkedList<>();
for (ClassInfo info : data.getClassInfos()) {
if (!info.isTestable()) {
continue;
}
/*
* there is a minimum that is equal to all jobs,
* plus extra time based on number of branches
*/
int budget = 60 * scheduler.getConfiguration().minMinutesPerJob + (int) (timePerBranch * info.numberOfBranches);
if (budget > maximumBudgetPerCore) {
/*
* Need to guarantee that no job has more than
* maximumBudgetPerCore regardless of number of cores
*/
totalLeftOver += (budget - maximumBudgetPerCore);
budget = maximumBudgetPerCore;
}
JobDefinition job = new JobDefinition(budget, scheduler.getConfiguration().getConstantMemoryPerJob(), info.getClassName(), 0, null, null);
jobs.add(job);
}
if (totalLeftOver > 0) {
/*
* we still have some more budget to allocate
*/
distributeExtraBudgetEvenly(jobs, totalLeftOver, maximumBudgetPerCore);
}
/*
* using scheduling theory, there could be different
* best orders to maximize CPU usage.
* Here, at least for the time being, for simplicity
* we just try to execute the most expensive jobs
* as soon as possible
*/
Collections.sort(jobs, (a, b) -> {
/*
* the job with takes most time will be "lower".
* recall that sorting is in ascending order
*/
return b.seconds - a.seconds;
});
return jobs;
}
use of org.evosuite.continuous.project.ProjectStaticData.ClassInfo in project evosuite by EvoSuite.
the class ScheduleType method createScheduleForWhenNotEnoughBudget.
/**
* if there is not enough search budget, then try
* to target as many CUTs as possible
* @return
*/
protected List<JobDefinition> createScheduleForWhenNotEnoughBudget() {
ProjectStaticData data = scheduler.getProjectData();
int totalBudget = 60 * scheduler.getConfiguration().timeInMinutes * scheduler.getConfiguration().getNumberOfUsableCores();
List<JobDefinition> jobs = new LinkedList<JobDefinition>();
// not enough budget
for (ClassInfo info : data.getClassInfos()) {
if (!info.isTestable()) {
continue;
}
JobDefinition job = new JobDefinition(60 * scheduler.getConfiguration().minMinutesPerJob, scheduler.getConfiguration().getConstantMemoryPerJob(), info.getClassName(), 0, null, null);
jobs.add(job);
totalBudget -= (60 * scheduler.getConfiguration().minMinutesPerJob);
if (totalBudget <= 0) {
break;
}
}
return jobs;
}
Aggregations