You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pd...@apache.org on 2014/07/02 16:53:31 UTC
svn commit: r1607386 - in
/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.benchmark/src/org/apache/felix/dm/benchmark:
controller/impl/ScenarioControllerImpl.java dependencymanager/Activator.java
Author: pderop
Date: Wed Jul 2 14:53:31 2014
New Revision: 1607386
URL: http://svn.apache.org/r1607386
Log:
code cleanup.
Modified:
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.benchmark/src/org/apache/felix/dm/benchmark/controller/impl/ScenarioControllerImpl.java
felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.benchmark/src/org/apache/felix/dm/benchmark/dependencymanager/Activator.java
Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.benchmark/src/org/apache/felix/dm/benchmark/controller/impl/ScenarioControllerImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.benchmark/src/org/apache/felix/dm/benchmark/controller/impl/ScenarioControllerImpl.java?rev=1607386&r1=1607385&r2=1607386&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.benchmark/src/org/apache/felix/dm/benchmark/controller/impl/ScenarioControllerImpl.java (original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.benchmark/src/org/apache/felix/dm/benchmark/controller/impl/ScenarioControllerImpl.java Wed Jul 2 14:53:31 2014
@@ -83,12 +83,12 @@ public class ScenarioControllerImpl impl
bundle.stop();
}));
- // Start/stop 30 times the tested bundles. (no processing done in components start/stop methods).
+ // Start/stop several times the tested bundles. (no processing done in components start/stop methods).
m_doProcessingInStartStop = false;
out.println("\n\t+++++ Starting benchmarks without processing done in components start/stop methods.");
- startStopScenarioBundles(10);
+ startStopScenarioBundles(30);
- // Start/stop 5 times the tested bundles (processing is done in components start/stop methods).
+ // Start/stop several times the tested bundles (processing is done in components start/stop methods).
m_doProcessingInStartStop = true;
out.println("\n\t+++++ Starting benchmarks with processing done in components start/stop methods.");
startStopScenarioBundles(5);
@@ -142,18 +142,18 @@ public class ScenarioControllerImpl impl
.peek(i -> out.print("."))
.map(n -> durationOf(() -> startAndStop(bundle)))
.sorted().boxed().collect(toList());
- displaySortedResults(sortedResults, iterations);
+ displaySortedResults(sortedResults);
Unchecked.run(() -> Thread.sleep(500));
});
}
- private void displaySortedResults(List<Long> sortedResults, int iterations) {
+ private void displaySortedResults(List<Long> sortedResults) {
// We don't display an average of the duration times; Instead, we sort the results,
// and we display the significant results (the first entry is the fastest, the middle entry is the
// average, the last entry is the slowest ...)
out.println("\n results=" +
Stream.of(0f, 24.99f, 49.99f, 74.99f, 99.99f)
- .mapToInt(perc -> (int) (perc * iterations / 100))
+ .mapToInt(perc -> (int) (perc * sortedResults.size() / 100))
.mapToObj(sortedResults::get).map(Object::toString)
.collect(joining(",")));
}
Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.benchmark/src/org/apache/felix/dm/benchmark/dependencymanager/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.benchmark/src/org/apache/felix/dm/benchmark/dependencymanager/Activator.java?rev=1607386&r1=1607385&r2=1607386&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.benchmark/src/org/apache/felix/dm/benchmark/dependencymanager/Activator.java (original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.benchmark/src/org/apache/felix/dm/benchmark/dependencymanager/Activator.java Wed Jul 2 14:53:31 2014
@@ -75,15 +75,12 @@ public class Activator extends Dependenc
dm.setThreadPool(Helper.getThreadPool());
}
- // Create the list of Artists, Albums, and music Tracks services.
List<Component> components = new ArrayList<>();
IntStream.range(0, ARTISTS)
.mapToObj(i -> createArtists(dm)).peek(components::add)
.flatMap(artist -> createAlbums(dm, artist)).peek(components::add)
.flatMap(album -> createTracks(dm, album)).forEach(components::add);
-
-
- // And add them all in our depednency manager.
+
components.stream().forEach(dm::add);
}
@@ -97,7 +94,7 @@ public class Activator extends Dependenc
}
private Stream<Component> createAlbums(DependencyManager dm, Component artist) {
- return IntStream.iterate(0, n -> n+1).limit(ALBUMS).mapToObj(i -> {
+ return IntStream.range(0, ALBUMS).mapToObj(i -> {
long id = Helper.generateId();
String filter = "(id=" + id + ")";
artist.add(dm.createServiceDependency().setService(Album.class, filter).setRequired(true)
@@ -115,7 +112,7 @@ public class Activator extends Dependenc
}
private Stream<Component> createTracks(DependencyManager dm, Component album) {
- return IntStream.iterate(0, n -> n+1).limit(TRACKS).mapToObj(i -> {
+ return IntStream.range(0, TRACKS).mapToObj(i -> {
long id = Helper.generateId();
String f = "(id=" + String.valueOf(id) + ")";
album.add(dm.createServiceDependency()