summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcontrib/benchmarks/apache-commons/benchmark.sh7
-rw-r--r--contrib/benchmarks/apache-commons/pom.xml24
-rw-r--r--contrib/benchmarks/apache-commons/src/test/java/org/uscxml/benchmark/BenchmarkTest.java96
-rwxr-xr-xcontrib/benchmarks/lxsc/benchmark.sh8
-rw-r--r--contrib/benchmarks/lxsc/test-performance.lua38
-rwxr-xr-xtest/benchmarks/createBenchmarks.pl6
-rw-r--r--test/benchmarks/finalParallel.scxml2
-rw-r--r--test/benchmarks/findLCCA.scxml2
8 files changed, 180 insertions, 3 deletions
diff --git a/contrib/benchmarks/apache-commons/benchmark.sh b/contrib/benchmarks/apache-commons/benchmark.sh
new file mode 100755
index 0000000..ec312a1
--- /dev/null
+++ b/contrib/benchmarks/apache-commons/benchmark.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -e
+
+# mvn archetype:generate -DgroupId=org.uscxml.benchmark -DartifactId=benchmark -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
+
+mvn test \ No newline at end of file
diff --git a/contrib/benchmarks/apache-commons/pom.xml b/contrib/benchmarks/apache-commons/pom.xml
new file mode 100644
index 0000000..58f6f14
--- /dev/null
+++ b/contrib/benchmarks/apache-commons/pom.xml
@@ -0,0 +1,24 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.uscxml.benchmark</groupId>
+ <artifactId>benchmark</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>benchmark</name>
+ <url>http://maven.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-scxml2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/contrib/benchmarks/apache-commons/src/test/java/org/uscxml/benchmark/BenchmarkTest.java b/contrib/benchmarks/apache-commons/src/test/java/org/uscxml/benchmark/BenchmarkTest.java
new file mode 100644
index 0000000..0888646
--- /dev/null
+++ b/contrib/benchmarks/apache-commons/src/test/java/org/uscxml/benchmark/BenchmarkTest.java
@@ -0,0 +1,96 @@
+package org.uscxml.benchmark;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.commons.scxml2.*;
+
+import org.apache.commons.scxml2.env.SimpleDispatcher;
+import org.apache.commons.scxml2.env.SimpleErrorReporter;
+import org.apache.commons.scxml2.env.Tracer;
+import org.apache.commons.scxml2.io.SCXMLReader;
+import org.apache.commons.scxml2.io.SCXMLReader.Configuration;
+import org.apache.commons.scxml2.model.CustomAction;
+import org.apache.commons.scxml2.model.EnterableState;
+import org.apache.commons.scxml2.model.Transition;
+import org.apache.commons.scxml2.model.SCXML;
+import org.apache.commons.scxml2.model.TransitionTarget;
+import org.apache.commons.scxml2.model.EnterableState;
+import org.apache.commons.scxml2.model.TransitionTarget;
+
+/**
+ * Unit test for simple App.
+ */
+public class BenchmarkTest extends TestCase {
+
+ class PerformanceListener extends SimpleErrorReporter implements SCXMLListener {
+ public long iterations = 0;
+ public long mark = System.currentTimeMillis();
+
+ public void onEntry(final EnterableState state) {
+ if (state.getId().equals("p0")) {
+ iterations++;
+ long now = System.currentTimeMillis();
+ if (now - mark > 1000) {
+ System.out.println(iterations);
+ mark = now;
+ iterations = 0;
+ }
+ }
+ }
+ public void onExit(final EnterableState state) {}
+ public void onTransition(final TransitionTarget from, final TransitionTarget to, final Transition transition, String event) {}
+
+ }
+
+ public SCXML parse(final URL url, final List<CustomAction> customActions) throws Exception {
+ Configuration configuration = new Configuration(null, null, customActions);
+ SCXML scxml = SCXMLReader.read(url, configuration);
+ return scxml;
+ }
+
+ public SCXMLExecutor getExecutor(final SCXML scxml, final Evaluator evaluator, final EventDispatcher eventDispatcher) throws Exception {
+ PerformanceListener trc = new PerformanceListener();
+ SCXMLExecutor exec = new SCXMLExecutor(evaluator, eventDispatcher, null);
+ exec.setStateMachine(scxml);
+ exec.addListener(scxml, trc);
+ return exec;
+ }
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public BenchmarkTest( String testName )
+ {
+ super( testName );
+ }
+
+ /**
+ * @return the suite of tests being tested
+ */
+ public static Test suite()
+ {
+ return new TestSuite( BenchmarkTest.class );
+ }
+
+ /**
+ * Rigourous Test :-)
+ */
+ public void testApp()
+ {
+ try {
+ SCXML scxml = parse(new URL("file:../../../test/benchmarks/findLCCA.scxml"), null);
+ SCXMLExecutor exec = getExecutor(scxml, null, new SimpleDispatcher());
+ exec.go();
+ } catch (Exception e) {
+ System.err.println(e);
+ assertTrue(false);
+ }
+ }
+}
diff --git a/contrib/benchmarks/lxsc/benchmark.sh b/contrib/benchmarks/lxsc/benchmark.sh
new file mode 100755
index 0000000..d0860ad
--- /dev/null
+++ b/contrib/benchmarks/lxsc/benchmark.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+
+git clone https://github.com/Phrogz/LXSC.git
+cp ../../../test/benchmarks/findLCCA.scxml ./test.scxml
+
+lua ./test-performance.lua \ No newline at end of file
diff --git a/contrib/benchmarks/lxsc/test-performance.lua b/contrib/benchmarks/lxsc/test-performance.lua
new file mode 100644
index 0000000..111fffa
--- /dev/null
+++ b/contrib/benchmarks/lxsc/test-performance.lua
@@ -0,0 +1,38 @@
+#!/usr/bin/env lua
+
+package.path = 'LXSC/?.lua;' .. package.path
+
+require 'io'
+require 'os'
+local LXSC = require 'lxsc'
+
+local c,t,lxsc = os.clock
+
+local out = io.open(string.format("results-%s.txt",LXSC.VERSION),"w")
+local sum=0
+function mark(msg,t2,n)
+ local delta = (t2-t)*1000/(n or 1)
+ sum = sum + delta
+ out:write(string.format("%25s: %5.2fms\n",msg,delta))
+end
+
+local xml = io.open("test.scxml"):read("*all")
+t = c()
+for i=1,20 do lxsc = LXSC:parse(xml) end
+mark("Parse XML",c(),20)
+
+lxsc.onAfterEnter = function(id,kind)
+ if (id=="id401") then
+ print("Entered "..kind.." '"..tostring(id).."'")
+ end
+end
+
+t = c()
+lxsc:start()
+mark("Start Machine",c())
+
+
+out:write("----------------------------------\n")
+out:write(string.format("%25s: %5.2fms ± 20%%\n","Total time",sum))
+
+out:close() \ No newline at end of file
diff --git a/test/benchmarks/createBenchmarks.pl b/test/benchmarks/createBenchmarks.pl
index 088c020..cd5cef7 100755
--- a/test/benchmarks/createBenchmarks.pl
+++ b/test/benchmarks/createBenchmarks.pl
@@ -40,6 +40,7 @@ sub createFindLCCABenchmark {
$$where->{'name'} = 'findLCCA';
$$where->{'type'} = 'scxml';
+ $$where->{'datamodel'} = 'null';
$$where->{'intial'} = "";
for (my $i = 1; $i <= $parallelStates; $i++) {
$$where->{'initial'} .= "id" . ($i*$nestingDepth) . " ";
@@ -84,6 +85,7 @@ sub createFinalParallelBenchmark {
$$where->{'name'} = 'finalParallel';
$$where->{'type'} = 'scxml';
+ $$where->{'datamodel'} = 'null';
$$where->{'intial'} = "";
$$where->{'children'}[0]->{'type'} = 'parallel';
@@ -111,7 +113,7 @@ sub createFinalParallelNestedFinals {
$state->{'type'} = "state";
}
$state->{'id'} = "id".$stateId++;
-
+
createFinalParallelNestedFinals(\$state->{'children'}, $amount - 1);
push @{$$where}, $state;
@@ -172,6 +174,8 @@ sub writeMachine {
print $fh ' seed="' . $seed . '"';
print $fh ' name="' . $machine->{'name'} . '"' if $machine->{'name'};
print $fh ' initial="' . $machine->{'initial'} . '"' if $machine->{'initial'};
+ print $fh ' xmlns="http://www.w3.org/2005/07/scxml"';
+ print $fh ' version="1.0"';
print $fh '>';
foreach (@{$machine->{'children'}}) {
diff --git a/test/benchmarks/finalParallel.scxml b/test/benchmarks/finalParallel.scxml
index 415c4d2..193fa1c 100644
--- a/test/benchmarks/finalParallel.scxml
+++ b/test/benchmarks/finalParallel.scxml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<scxml seed="681439801" name="finalParallel">
+<scxml xmlns="http://www.w3.org/2005/07/scxml" datamodel="null" seed="117612236" name="finalParallel" version="1.0">
<parallel id="p0">
<state id="id1">
<state id="id2">
diff --git a/test/benchmarks/findLCCA.scxml b/test/benchmarks/findLCCA.scxml
index 068057f..290a323 100644
--- a/test/benchmarks/findLCCA.scxml
+++ b/test/benchmarks/findLCCA.scxml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<scxml seed="681439801" name="findLCCA" initial="id20 id40 id60 id80 id100 id120 id140 id160 id180 id200 id220 id240 id260 id280 id300 id320 id340 id360 id380 id400 ">
+<scxml xmlns="http://www.w3.org/2005/07/scxml" datamodel="null" seed="117612236" name="findLCCA" initial="id20 id40 id60 id80 id100 id120 id140 id160 id180 id200 id220 id240 id260 id280 id300 id320 id340 id360 id380 id400 " version="1.0">
<parallel id="p0">
<state id="id1">
<state id="id2">