Skip to content

Commit

Permalink
Separation of Profiler into separate class, and a number of bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophos-Elias-Vasylenko committed Oct 27, 2015
1 parent 7880cbb commit 977a4dd
Show file tree
Hide file tree
Showing 16 changed files with 363 additions and 220 deletions.
6 changes: 4 additions & 2 deletions cnf/build.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ Bundle-Version: ${modabi-version}.${tstamp}
# -baseline: *
-releaserepo: Release

modabi-bnd-plugin: ${workspace}/uk.co.strangeskies.modabi.bnd/generated/uk.co.strangeskies.modabi.bnd.${1}.jar

pluginpath.modabi: \
${build}/release/uk.co.strangeskies.modabi.bnd.core/uk.co.strangeskies.modabi.bnd.core-${modabi-version}.jar,\
${build}/release/uk.co.strangeskies.modabi.bnd.xml/uk.co.strangeskies.modabi.bnd.xml-${modabi-version}.jar
${modabi-bnd-plugin;core},\
${modabi-bnd-plugin;xml},\

-pluginpath.base: \
${build}/cache/biz.aQute.repository.aether.jar; \
Expand Down
2 changes: 1 addition & 1 deletion cnf/local/index.xml.sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
00d32998f75fb42424a40b7de9e81e4dc9be2ca6a9fc3f2d3bec406919d62140
8de8e8866152096f0c4ea5ddd6ed1d633b4d1a6edfbd823245cb57f6639732fd
12 changes: 12 additions & 0 deletions uk.co.strangeskies.modabi.benchmarks/benchmarker.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Bundle-Name: Modabi :: Benchmarker

-pluginpath: \
${pluginpath.modabi}

-plugin: \
uk.co.strangeskies.modabi.bnd.xml.ModabiXmlRegistration

-includeresource: \
META-INF/modabi=schemata

Export-Package: uk.co.strangeskies.modabi.benchmark
31 changes: 31 additions & 0 deletions uk.co.strangeskies.modabi.benchmarks/benchmarker.bndrun
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-runrequires: \
osgi.identity;filter:='(osgi.identity=osgi.enroute.logger.simple.provider)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.utilities.osgi.consolelog)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.runtime)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.modabi.io.xml.provider)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.modabi.benchmarks.benchmarker)'

-runvm: -XX:MaxJavaStackTraceDepth=1000000
-runfw: org.apache.felix.framework;version='[5.2.0,5.2.0]'

-runbundles: \
org.apache.commons.lang3;version='[3.4.0,3.4.1)',\
org.apache.felix.gogo.command;version='[0.14.0,0.14.1)',\
org.apache.felix.gogo.runtime;version='[0.16.2,0.16.3)',\
org.apache.felix.gogo.shell;version='[0.10.0,0.10.1)',\
org.apache.felix.log;version='[1.0.1,1.0.2)',\
org.apache.felix.metatype;version='[1.1.2,1.1.3)',\
org.apache.felix.scr;version='[2.0.0,2.0.1)',\
org.apache.servicemix.bundles.stax-utils;version='[20070216.0.0,20070216.0.1)',\
osgi.enroute.logger.simple.provider;version='[1.2.1,1.2.2)',\
uk.co.strangeskies.mathematics;version='[1.0.13,1.0.14)',\
uk.co.strangeskies.modabi.benchmarks.benchmarker;version=snapshot,\
uk.co.strangeskies.modabi.core.api;version=snapshot,\
uk.co.strangeskies.modabi.core.provider;version=snapshot,\
uk.co.strangeskies.modabi.io.xml.provider;version=snapshot,\
uk.co.strangeskies.reflection;version='[1.0.13,1.0.14)',\
uk.co.strangeskies.utilities;version='[1.0.13,1.0.14)',\
uk.co.strangeskies.utilities.osgi.consolelog;version='[1.0.13,1.0.14)'
-runee: JavaSE-1.8
44 changes: 2 additions & 42 deletions uk.co.strangeskies.modabi.benchmarks/bnd.bnd
Original file line number Diff line number Diff line change
@@ -1,56 +1,16 @@
Bundle-Name: Modabi :: Benchmarks
Bundle-Description: \
Benchmarks comparing Modabi to simple parsers.\
\
${modabi-description}
-sub: *.bnd

-runee: JavaSE-1.8

-pluginpath: \
${pluginpath.modabi}

-plugin: \
uk.co.strangeskies.modabi.bnd.xml.ModabiXmlRegistration

-buildpath: \
${ss;utilities},\
${ss;reflection},\
${ss;mathematics},\
uk.co.strangeskies.modabi.core.api;version=project,\
org.apache.commons.lang3

-includeresource: \
META-INF/modabi=schemata

-runrequires: \
osgi.identity;filter:='(osgi.identity=osgi.enroute.logger.simple.provider)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.utilities.osgi.consolelog)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.runtime)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.modabi.benchmarks)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.modabi.io.xml.provider)'

-runfw: org.eclipse.osgi;version='[3.10.100.v20150529-1857,3.10.100.v20150529-1857]'

-runbundles: \
org.apache.commons.lang3;version='[3.4.0,3.4.1)',\
org.apache.felix.gogo.command;version='[0.14.0,0.14.1)',\
org.apache.felix.gogo.runtime;version='[0.16.2,0.16.3)',\
org.apache.felix.gogo.shell;version='[0.10.0,0.10.1)',\
org.apache.felix.log;version='[1.0.1,1.0.2)',\
org.apache.felix.metatype;version='[1.1.2,1.1.3)',\
org.apache.felix.scr;version='[2.0.0,2.0.1)',\
org.apache.servicemix.bundles.stax-utils;version='[20070216.0.0,20070216.0.1)',\
osgi.enroute.logger.simple.provider;version='[1.2.1,1.2.2)',\
uk.co.strangeskies.mathematics;version='[1.0.13,1.0.14)',\
uk.co.strangeskies.modabi.benchmarks;version=snapshot,\
uk.co.strangeskies.modabi.core.api;version=snapshot,\
uk.co.strangeskies.modabi.core.provider;version=snapshot,\
uk.co.strangeskies.modabi.io.xml.provider;version=snapshot,\
uk.co.strangeskies.reflection;version='[1.0.13,1.0.14)',\
uk.co.strangeskies.utilities;version='[1.0.13,1.0.14)',\
uk.co.strangeskies.utilities.osgi.consolelog;version='[1.0.13,1.0.14)'

-runvm: -XX:MaxJavaStackTraceDepth=1000000
Export-Package: uk.co.strangeskies.modabi.benchmark
-runvm: -XX:MaxJavaStackTraceDepth=1000000
8 changes: 8 additions & 0 deletions uk.co.strangeskies.modabi.benchmarks/profiler.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bundle-Name: Modabi :: Profiler

Private-Package: uk.co.strangeskies.modabi.profile
Import-Package: \
uk.co.strangeskies.modabi.schema.building,\
uk.co.strangeskies.modabi.io,\
uk.co.strangeskies.modabi,\
*
31 changes: 31 additions & 0 deletions uk.co.strangeskies.modabi.benchmarks/profiler.bndrun
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-runrequires: \
osgi.identity;filter:='(osgi.identity=osgi.enroute.logger.simple.provider)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.utilities.osgi.consolelog)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.runtime)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.modabi.io.xml.provider)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.modabi.benchmarks.profiler)',\
osgi.identity;filter:='(osgi.identity=uk.co.strangeskies.modabi.core.provider)'

-runvm: -XX:MaxJavaStackTraceDepth=1000000
-runfw: org.apache.felix.framework;version='[5.2.0,5.2.0]'

-runbundles: \
org.apache.felix.gogo.command;version='[0.14.0,0.14.1)',\
org.apache.felix.gogo.runtime;version='[0.16.2,0.16.3)',\
org.apache.felix.gogo.shell;version='[0.10.0,0.10.1)',\
org.apache.felix.log;version='[1.0.1,1.0.2)',\
org.apache.felix.metatype;version='[1.1.2,1.1.3)',\
org.apache.felix.scr;version='[2.0.0,2.0.1)',\
org.apache.servicemix.bundles.stax-utils;version='[20070216.0.0,20070216.0.1)',\
osgi.enroute.logger.simple.provider;version='[1.2.1,1.2.2)',\
uk.co.strangeskies.mathematics;version='[1.0.13,1.0.14)',\
uk.co.strangeskies.modabi.benchmarks.profiler;version=snapshot,\
uk.co.strangeskies.modabi.core.api;version=snapshot,\
uk.co.strangeskies.modabi.core.provider;version=snapshot,\
uk.co.strangeskies.modabi.io.xml.provider;version=snapshot,\
uk.co.strangeskies.reflection;version='[1.0.13,1.0.14)',\
uk.co.strangeskies.utilities;version='[1.0.13,1.0.14)',\
uk.co.strangeskies.utilities.osgi.consolelog;version='[1.0.13,1.0.14)'
-runee: JavaSE-1.8
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
Expand All @@ -36,14 +38,14 @@
import org.apache.commons.lang3.RandomUtils;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.wiring.BundleWiring;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.log.LogService;

import uk.co.strangeskies.modabi.SchemaManager;
import uk.co.strangeskies.modabi.io.structured.DataInterface;
import uk.co.strangeskies.utilities.ContextClassLoaderRunner;

@Component
Expand All @@ -65,90 +67,96 @@ public void setLogger(LogService logger) {
this.logger = logger;
}

private void log(int level, String message) {
if (logger != null)
logger.log(level, message);
}

@Activate
public void run(BundleContext context) throws BundleException {
new ContextClassLoaderRunner(
context.getBundle().adapt(BundleWiring.class).getClassLoader())
.run(() -> {
try {
logger.log(LogService.LOG_INFO, "Preparing benchmark...");

File outputDir = new File(OUTPUT_FOLDER);
if (!outputDir.exists()) {
logger.log(LogService.LOG_INFO, "Creating output directory: "
+ outputDir.getAbsolutePath());

if (!outputDir.mkdirs()) {
throw new IllegalStateException(
"Could not create output directory, aborting...");
}
}

System.out.println("test");
manager.bindSchema()
.from(context.getBundle()
.getResource("/META-INF/modabi/BenchmarkSchema.xml")
.openStream())
.resolve(500);

System.out.println("test2");

boolean createXml = false;
logger.log(LogService.LOG_INFO,
"Will create XML files? " + createXml);
if (createXml) {
createXmlPortfolio();
}

System.gc();
System.gc();

for (int i = 0; i < 10; i++) {
readLargeXmlWithModabi(new File(OUTPUT_FOLDER
+ File.separatorChar + "large-person-100.xml"));
readLargeXmlWithModabi(new File(OUTPUT_FOLDER
+ File.separatorChar + "large-person-1000.xml"));
readLargeXmlWithModabi(new File(OUTPUT_FOLDER
+ File.separatorChar + "large-person-10000.xml"));

readLargeXmlWithStax(new File(OUTPUT_FOLDER
+ File.separatorChar + "large-person-100.xml"));
readLargeXmlWithStax(new File(OUTPUT_FOLDER
+ File.separatorChar + "large-person-1000.xml"));
readLargeXmlWithStax(new File(OUTPUT_FOLDER
+ File.separatorChar + "large-person-10000.xml"));

readLargeXmlWithFasterStax(new File(OUTPUT_FOLDER
+ File.separatorChar + "large-person-100.xml"));
readLargeXmlWithFasterStax(new File(OUTPUT_FOLDER
+ File.separatorChar + "large-person-1000.xml"));
readLargeXmlWithFasterStax(new File(OUTPUT_FOLDER
+ File.separatorChar + "large-person-10000.xml"));
}
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
});
context.getBundle(0).stop();
try {
new ContextClassLoaderRunner(getClass().getClassLoader()).run(() -> {
try {
log(LogService.LOG_INFO, "Preparing benchmark...");

File outputDir = new File(OUTPUT_FOLDER);
if (!outputDir.exists()) {
log(LogService.LOG_INFO,
"Creating output directory: " + outputDir.getAbsolutePath());

if (!outputDir.mkdirs()) {
throw new IllegalStateException(
"Could not create output directory, aborting...");
}
}

System.out.println("test");
manager.bindSchema()
.from(context.getBundle()
.getResource("/META-INF/modabi/BenchmarkSchema.xml")
.openStream())
.resolve(500);

System.out.println("test2");

boolean createXml = false;
log(LogService.LOG_INFO, "Will create XML files? " + createXml);
if (createXml) {
createXmlPortfolio();
}

System.gc();
System.gc();

for (int i = 0; i < 10; i++) {
readLargeXmlWithModabi(new File(
OUTPUT_FOLDER + File.separatorChar + "large-person-100.xml"));
readLargeXmlWithModabi(new File(
OUTPUT_FOLDER + File.separatorChar + "large-person-1000.xml"));
readLargeXmlWithModabi(new File(
OUTPUT_FOLDER + File.separatorChar + "large-person-10000.xml"));

readLargeXmlWithStax(new File(
OUTPUT_FOLDER + File.separatorChar + "large-person-100.xml"));
readLargeXmlWithStax(new File(
OUTPUT_FOLDER + File.separatorChar + "large-person-1000.xml"));
readLargeXmlWithStax(new File(
OUTPUT_FOLDER + File.separatorChar + "large-person-10000.xml"));

readLargeXmlWithFasterStax(new File(
OUTPUT_FOLDER + File.separatorChar + "large-person-100.xml"));
readLargeXmlWithFasterStax(new File(
OUTPUT_FOLDER + File.separatorChar + "large-person-1000.xml"));
readLargeXmlWithFasterStax(new File(
OUTPUT_FOLDER + File.separatorChar + "large-person-10000.xml"));
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
});
} catch (Throwable t) {
t.printStackTrace();
throw t;
} finally {
context.getBundle(0).stop();
}
}

private void createXmlPortfolio() throws Exception {
createXml(100, OUTPUT_FOLDER + File.separatorChar + "large-person-100.xml");
logger.log(LogService.LOG_INFO,
log(LogService.LOG_INFO,
"Completed generation of large XML with 100 entries...");

createXml(1000,
OUTPUT_FOLDER + File.separatorChar + "large-person-1000.xml");
logger.log(LogService.LOG_INFO,
log(LogService.LOG_INFO,
"Completed generation of large XML with 1,000 entries...");

createXml(10000,
OUTPUT_FOLDER + File.separatorChar + "large-person-10000.xml");
logger.log(LogService.LOG_INFO,
log(LogService.LOG_INFO,
"Completed generation of large XML with 10,000 entries...");
}

Expand Down Expand Up @@ -193,7 +201,7 @@ private void readLargeXmlWithModabi(File file)

long end = System.currentTimeMillis();

logger.log(LogService.LOG_INFO,
log(LogService.LOG_INFO,
"Modabi - (" + file + "): Time taken in ms: " + (end - start));
}

Expand Down Expand Up @@ -226,7 +234,7 @@ private void readLargeXmlWithStax(File file) throws FactoryConfigurationError,

long end = System.currentTimeMillis();

logger.log(LogService.LOG_INFO,
log(LogService.LOG_INFO,
"STax - (" + file + "): Time taken in ms: " + (end - start));
}
}
Expand Down Expand Up @@ -261,7 +269,7 @@ private void readLargeXmlWithFasterStax(File file)

long end = System.currentTimeMillis();

logger.log(LogService.LOG_INFO,
log(LogService.LOG_INFO,
"Woodstox - (" + file + "): Time taken in ms: " + (end - start));
}
}
Expand Down
Loading

0 comments on commit 977a4dd

Please sign in to comment.