From 578e6395aa073017cfb41ce98bc35f673be5ee6c Mon Sep 17 00:00:00 2001 From: Michael Schmid Date: Sun, 28 Jun 2020 17:02:15 +0200 Subject: [PATCH] Changes in Testenvironment --- src/main/java/mvd/jester/App.java | 49 ++++++++++++++++++++++++++++++------------------- src/main/java/mvd/jester/TestEnvironment.java | 22 +++++++++------------- 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/main/java/mvd/jester/App.java b/src/main/java/mvd/jester/App.java index a0a7a2d..9142a2b 100644 --- a/src/main/java/mvd/jester/App.java +++ b/src/main/java/mvd/jester/App.java @@ -17,28 +17,39 @@ import mvd.jester.tests.SchmidMottok; */ public class App { public static void main(String[] args) { - { - SystemManager manager = new SystemManager(8); - DagTaskBuilder builder = new DagTaskBuilder(); - TestEnvironment te = new TestEnvironment(); + // { + // SystemManager manager = new SystemManager(8); + // DagTaskBuilder builder = new DagTaskBuilder(); + // TestEnvironment te = new TestEnvironment(); - List> tests = - te.registerTests(Arrays.asList(new SchmidMottok(manager), - new MelaniButtazzo(manager), new FonsecaNelis(manager))); + // List> tests = + // te.registerTests(Arrays.asList(new SchmidMottok(manager), + // new MelaniButtazzo(manager), new FonsecaNelis(manager))); - te.varyUtilization(builder, tests, 8, 500); - } - { - SystemManager manager = new SystemManager(8); - DagTaskBuilder builder = new DagTaskBuilder(); - TestEnvironment te = new TestEnvironment(); + // te.varyUtilization(builder, tests, 8, 500); + // } + // { + // SystemManager manager = new SystemManager(8); + // DagTaskBuilder builder = new DagTaskBuilder(); + // TestEnvironment te = new TestEnvironment(); - List> tests = - te.registerTests(Arrays.asList(new SchmidMottok(manager), - new MelaniButtazzo(manager), new FonsecaNelis(manager))); + // List> tests = + // te.registerTests(Arrays.asList(new SchmidMottok(manager), + // new MelaniButtazzo(manager), new FonsecaNelis(manager))); - te.varyNumberOfProcessors(builder, tests, manager, 500); - } + // te.varyNumberOfProcessors(builder, tests, manager, 500); + // } + // { + // SystemManager manager = new SystemManager(8); + // DagTaskBuilder builder = new DagTaskBuilder(); + // TestEnvironment te = new TestEnvironment(); + + // List> tests = + // te.registerTests(Arrays.asList(new SchmidMottok(manager), + // new MelaniButtazzo(manager), new FonsecaNelis(manager))); + + // te.varyNumberOfTasks(builder, tests, 8, 500); + // } { SystemManager manager = new SystemManager(8); DagTaskBuilder builder = new DagTaskBuilder(); @@ -48,7 +59,7 @@ public class App { te.registerTests(Arrays.asList(new SchmidMottok(manager), new MelaniButtazzo(manager), new FonsecaNelis(manager))); - te.varyNumberOfTasks(builder, tests, 8, 500); + te.measureExecutionTimes(builder, tests, manager, 500); } } } diff --git a/src/main/java/mvd/jester/TestEnvironment.java b/src/main/java/mvd/jester/TestEnvironment.java index 1ba1a20..8d57ad0 100644 --- a/src/main/java/mvd/jester/TestEnvironment.java +++ b/src/main/java/mvd/jester/TestEnvironment.java @@ -1,5 +1,6 @@ package mvd.jester; +import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -7,8 +8,6 @@ import java.util.Map; import java.util.Set; import java.util.Map.Entry; import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.TimeUnit; -import com.google.common.base.Stopwatch; import mvd.jester.info.SchedulingInfo; import mvd.jester.info.SchedulingInfo.Feasiblity; import mvd.jester.model.DagTask; @@ -81,21 +80,21 @@ public class TestEnvironment { public void measureExecutionTimes(final DagTaskBuilder builder, final List> abstractTestInstances, - final long numberOfMeasurements) { + SystemManager manager, final long numberOfMeasurements) { Map, List> results = new LinkedHashMap<>(); abstractTestInstances.forEach(t -> results.put(t, new ArrayList<>())); for (int i = 0; i < numberOfMeasurements; ++i) { - double utilization = ThreadLocalRandom.current().nextDouble(1, 7); + double utilization = ThreadLocalRandom.current().nextDouble(1, manager.getNumberOfProcessors()); Set taskSet = builder.generateTaskSet(utilization); for (AbstractTest testInstance : abstractTestInstances) { final PriorityManager priorityManager = testInstance.getPriorityManager(); final SortedTaskSet sortedTaskSet = new SortedTaskSet<>(priorityManager); sortedTaskSet.addAll(taskSet); - Stopwatch w = Stopwatch.createStarted(); + long timeBefore = ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime(); testInstance.runSchedulabilityCheck(sortedTaskSet); - w.stop(); - long micros = w.elapsed(TimeUnit.MICROSECONDS); + long timeAfter = ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime(); + long micros = (timeAfter-timeBefore)/1000; results.get(testInstance).add(micros); } } @@ -126,8 +125,7 @@ public class TestEnvironment { final Set taskSet = builder.generateUUnifastTaskSet( (long) (1.5 * numberOfProcessors), (double) numberOfProcessors * 0.5); - System.out.print(Math.round((double) checkedTasksets / numberOfTaskSets * 100) - + "% of " + numberOfTaskSets + " tasksets tested!\r"); + System.out.print(checkedTasksets +"/"+ numberOfTaskSets + " tasksets tested!\r"); for (final AbstractTest testInstance : abstractTestInstances) { final PriorityManager priorityManager = testInstance.getPriorityManager(); @@ -168,8 +166,7 @@ public class TestEnvironment { final Set taskSet = builder.generateUUnifastTaskSet(numberOfTasks, (double) numberOfProcessors * 0.5); - System.out.print(Math.round((double) checkedTasksets / numberOfTaskSets * 100) - + "% of " + numberOfTaskSets + " tasksets tested!\r"); + System.out.print(checkedTasksets +"/"+ numberOfTaskSets + " tasksets tested!\r"); for (final AbstractTest testInstance : abstractTestInstances) { final PriorityManager priorityManager = testInstance.getPriorityManager(); @@ -209,8 +206,7 @@ public class TestEnvironment { for (int i = 0; i < numberOfTaskSetsPerUtil; ++i) { final Set taskSet = builder.generateTaskSet(util); - System.out.print(Math.round((double) checkedTasksets / numberOfTaskSets * 100) - + "% of " + numberOfTaskSets + " tasksets tested!\r"); + System.out.print(checkedTasksets +"/"+ numberOfTaskSets + " tasksets tested!\r"); for (final AbstractTest testInstance : abstractTestInstances) { final PriorityManager priorityManager = testInstance.getPriorityManager(); -- libgit2 0.26.0