summaryrefslogtreecommitdiffstats
path: root/test/benchmarks/createBenchmarks.pl
diff options
context:
space:
mode:
Diffstat (limited to 'test/benchmarks/createBenchmarks.pl')
-rwxr-xr-xtest/benchmarks/createBenchmarks.pl164
1 files changed, 104 insertions, 60 deletions
diff --git a/test/benchmarks/createBenchmarks.pl b/test/benchmarks/createBenchmarks.pl
index cd5cef7..3c02dc3 100755
--- a/test/benchmarks/createBenchmarks.pl
+++ b/test/benchmarks/createBenchmarks.pl
@@ -9,56 +9,43 @@ no warnings 'recursion';
use Getopt::Long qw(GetOptions);
use Data::Dumper;
+my $size = 20;
my %options = ();
-GetOptions(
- \%options,
- "depth-max=i",
- "child-max=i",
- "events-max=i",
- "states-max=i",
- "trans-max=i",
- "random-seed=i"
-);
-
-my $seed = $options{'random-seed'} || int(rand(2**31));
-
-# $maxStates = 8;
-# $maxTrans = 8
-
-srand($seed);
my $machine;
my $stateId = 1;
+### Find LCCA ===========
-sub createFindLCCABenchmark {
+sub benchLCCA {
my $where = shift;
- my $nestingDepth = 20;
- my $parallelStates = 20;
+ my $nestingDepth = $size;
+ my $parallelStates = $size;
- $$where->{'name'} = 'findLCCA';
+ $$where->{'name'} = 'benchmark';
$$where->{'type'} = 'scxml';
$$where->{'datamodel'} = 'null';
- $$where->{'intial'} = "";
- for (my $i = 1; $i <= $parallelStates; $i++) {
- $$where->{'initial'} .= "id" . ($i*$nestingDepth) . " ";
- }
+ $$where->{'initial'} = "mark";
+ # SCION cannot have multiple states in its initial attribute
+ # for (my $i = 1; $i <= $parallelStates; $i++) {
+ # $$where->{'initial'} .= "id" . ($i*$nestingDepth) . " ";
+ # }
$$where->{'children'}[0]->{'type'} = 'parallel';
- $$where->{'children'}[0]->{'id'} = "p0";
+ $$where->{'children'}[0]->{'id'} = "mark";
for (my $i = 0; $i < $parallelStates; $i++) {
- createFindLCCANestedCompounds(\$$where->{'children'}[0]->{'children'}, $nestingDepth, $nestingDepth * $parallelStates + 1);
+ benchLCCANestedCompounds(\$$where->{'children'}[0]->{'children'}, $nestingDepth, $nestingDepth * $parallelStates + 1);
}
$$where->{'children'}[1]->{'type'} = 'state';
$$where->{'children'}[1]->{'id'} = "id".$stateId++;
- $$where->{'children'}[1]->{'transitions'}[0]->{'target'} = $$where->{'initial'};
+ $$where->{'children'}[1]->{'transitions'}[0]->{'target'} = "mark";
}
-sub createFindLCCANestedCompounds {
+sub benchLCCANestedCompounds {
my $where = shift;
my $amount = shift;
my $target = shift;
@@ -67,7 +54,7 @@ sub createFindLCCANestedCompounds {
my $state;
$state->{'id'} = "id".$stateId++;
$state->{'type'} = "state";
- createFindLCCANestedCompounds(\$state->{'children'}, $amount - 1, $target);
+ benchLCCANestedCompounds(\$state->{'children'}, $amount - 1, $target);
if ($amount == 1) {
$state->{'transitions'}[0]->{'target'} = "id".$target;
@@ -77,31 +64,32 @@ sub createFindLCCANestedCompounds {
}
}
-sub createFinalParallelBenchmark {
+### Final Parallel States ===========
+
+sub benchFinalParallel {
my $where = shift;
- my $nestingDepth = 20;
- my $finalStates = 20;
+ my $nestingDepth = $size;
+ my $finalStates = $size;
- $$where->{'name'} = 'finalParallel';
+ $$where->{'name'} = 'benchmark';
$$where->{'type'} = 'scxml';
$$where->{'datamodel'} = 'null';
- $$where->{'intial'} = "";
+ $$where->{'initial'} = "";
$$where->{'children'}[0]->{'type'} = 'parallel';
- $$where->{'children'}[0]->{'id'} = "p0";
+ $$where->{'children'}[0]->{'id'} = "mark";
- $$where->{'children'}[0]->{'transitions'}[0]->{'event'} = 'done.state.p0';
- $$where->{'children'}[0]->{'transitions'}[0]->{'target'} = 'p0';
+ $$where->{'children'}[0]->{'transitions'}[0]->{'event'} = 'done.state.mark';
+ $$where->{'children'}[0]->{'transitions'}[0]->{'target'} = 'mark';
for (my $i = 0; $i < $finalStates; $i++) {
- createFinalParallelNestedFinals(\$$where->{'children'}[0]->{'children'}, $nestingDepth);
+ benchFinalParallelNested(\$$where->{'children'}[0]->{'children'}, $nestingDepth);
}
-
}
-sub createFinalParallelNestedFinals {
+sub benchFinalParallelNested {
my $where = shift;
my $amount = shift;
@@ -114,13 +102,60 @@ sub createFinalParallelNestedFinals {
}
$state->{'id'} = "id".$stateId++;
- createFinalParallelNestedFinals(\$state->{'children'}, $amount - 1);
+ benchFinalParallelNested(\$state->{'children'}, $amount - 1);
push @{$$where}, $state;
}
}
+### Conflicting Transitions ===========
+
+sub benchConflictTrans {
+ my $where = shift;
+
+ my $nestingDepth = 1;
+ my $transitions = $size;
+
+ $$where->{'name'} = 'benchmark';
+ $$where->{'type'} = 'scxml';
+ $$where->{'datamodel'} = 'null';
+ $$where->{'initial'} = "";
+
+ $$where->{'children'}[0]->{'type'} = 'parallel';
+ $$where->{'children'}[0]->{'id'} = "mark";
+ for (my $i = 0; $i < $transitions; $i++) {
+ benchConflictTransNested(\$$where->{'children'}[0]->{'children'}, $nestingDepth);
+ }
+
+ $$where->{'children'}[1]->{'type'} = 'state';
+ $$where->{'children'}[1]->{'id'} = "id".$stateId++;
+ $$where->{'children'}[1]->{'transitions'}[0]->{'target'} = "mark";
+
+}
+
+sub benchConflictTransNested {
+ my $where = shift;
+ my $amount = shift;
+
+ if ($amount > 0) {
+ my $state;
+ $state->{'id'} = "id".$stateId++;
+ $state->{'type'} = "state";
+ benchConflictTransNested(\$state->{'children'}, $amount - 1);
+
+ if ($amount == 1) {
+ for (my $i = 0; $i < $size; $i++) {
+ $state->{'transitions'}[$i]->{'target'} = "mark";
+ }
+ }
+
+ push @{$$where}, $state;
+ }
+
+}
+
+
sub writeState {
my $state = shift;
my $fh = shift;
@@ -171,7 +206,6 @@ sub writeMachine {
print $fh '<scxml';
print $fh ' datamodel="' . $machine->{'datamodel'} . '"' if $machine->{'datamodel'};
- 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"';
@@ -187,25 +221,35 @@ sub writeMachine {
sub xmllint {
my $file = shift;
- `mv $file $file.unformatted.xml`;
- `xmllint --format $file.unformatted.xml > $file`;
- `rm $file.unformatted.xml`;
+ # `mv $file $file.unformatted.xml`;
+ # `xmllint --format $file.unformatted.xml > $file`;
+ # `rm $file.unformatted.xml`;
}
{
- $machine = {};
- $stateId = 1;
-
- createFindLCCABenchmark(\$machine);
- # print Dumper($machine);
- writeMachine($machine, "findLCCA.scxml");
- xmllint("findLCCA.scxml");
-
-
- $machine = {};
- $stateId = 1;
- createFinalParallelBenchmark(\$machine);
- writeMachine($machine, "finalParallel.scxml");
- xmllint("finalParallel.scxml");
-
+ for my $i (4, 16, 64, 256, 512) {
+ $size = $i;
+
+ $machine = {};
+ $stateId = 1;
+ benchLCCA(\$machine);
+ # print Dumper($machine);
+ writeMachine($machine, "LCCA.${size}.scxml");
+ xmllint("benchLCCA${size}.scxml");
+
+
+ # $machine = {};
+ # $stateId = 1;
+ # benchFinalParallel(\$machine);
+ # writeMachine($machine, "benchFinalParallel${size}.scxml");
+ # xmllint("benchFinalParallel${size}.scxml");
+
+
+ $machine = {};
+ $stateId = 1;
+ benchConflictTrans(\$machine);
+ # print Dumper($machine);
+ writeMachine($machine, "Transitions.${size}.scxml");
+ xmllint("benchConflictTrans${size}.scxml");
+ }
}