Skip to content

Commit

Permalink
Kitchen sink benchmark, fixes StoneCypher/fsl#738
Browse files Browse the repository at this point in the history
  • Loading branch information
StoneCypher committed May 13, 2022
1 parent 6dbad3d commit 024f2e2
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 75 deletions.
16 changes: 8 additions & 8 deletions benchmark/results/general.chart.html
Expand Up @@ -28,7 +28,7 @@
</head>
<body>
<div class="container">
<canvas id="chart1652406351455" width="16" height="9"></canvas>
<canvas id="chart1652414220626" width="16" height="9"></canvas>
</div>
<script>
const format = (num) => {
Expand All @@ -51,18 +51,18 @@
chunked.map((chunk) => chunk.join('')).join(' ') + fractionStr
)
}
const ctx1652406351455 = document
.getElementById('chart1652406351455')
const ctx1652414220626 = document
.getElementById('chart1652414220626')
.getContext('2d')
const chart1652406351455 = new Chart(ctx1652406351455, {
const chart1652414220626 = new Chart(ctx1652414220626, {
type: 'bar',
data: {
labels: ["Blind cycle a traffic light 500 times by transition","Blind cycle a traffic light 500 times by action","Blind cycle a basic-hooked traffic light 500 times by transition","Blind cycle a named-hooked traffic light 500 times by transition","Blind cycle an any-transition traffic light 500 times by transition","Blind cycle an exit hooked traffic light 500 times by transition","Blind cycle an enter hooked traffic light 500 times by transition","Blind cycle a standard-transition hooked light by transition","Blind cycle a main-transition hooked light by transition","Blind cycle a force-transition hooked light by transition","Blind cycle a traffic light 500 times by action","Blind cycle a basic-hooked traffic light 500 times by action","Blind cycle a named-hooked traffic light 500 times by action","Blind cycle an any-action traffic light 500 times by action","Blind cycle a global-action traffic light 500 times by action","Blind cycle an exit hooked traffic light 500 times by action","Blind cycle an enter hooked traffic light 500 times by action","Blind cycle a standard transition tl 500 times by action","Blind cycle a main transition tl 500 times by action","Blind cycle a forced transition tl 500 times by action"],
labels: ["Blind cycle a traffic light 500 times by transition","Blind cycle a traffic light 500 times by action","Blind cycle a basic-hooked traffic light 500 times by transition","Blind cycle a named-hooked traffic light 500 times by transition","Blind cycle an any-transition traffic light 500 times by transition","Blind cycle an exit hooked traffic light 500 times by transition","Blind cycle an enter hooked traffic light 500 times by transition","Blind cycle a standard-transition hooked light by transition","Blind cycle a main-transition hooked light by transition","Blind cycle a force-transition hooked light by transition","Blind cycle a traffic light 500 times by action","Blind cycle a basic-hooked traffic light 500 times by action","Blind cycle a named-hooked traffic light 500 times by action","Blind cycle an any-action traffic light 500 times by action","Blind cycle a global-action traffic light 500 times by action","Blind cycle an exit hooked traffic light 500 times by action","Blind cycle an enter hooked traffic light 500 times by action","Blind cycle a standard transition tl 500 times by action","Blind cycle a main transition tl 500 times by action","Blind cycle a forced transition tl 500 times by action","Kitchen Sink 500 times"],
datasets: [
{
data: [6604,14182,1365,6480,6277,5853,4842,5833,6031,25819,14108,1534,1393,11272,11357,9807,9968,71720,68833,60373],
backgroundColor: ["hsl(11.051999999999992, 85%, 55%)","hsl(23.723999999999997, 85%, 55%)","hsl(2.280000000000007, 85%, 55%)","hsl(10.848000000000008, 85%, 55%)","hsl(10.5, 85%, 55%)","hsl(9.791999999999996, 85%, 55%)","hsl(8.100000000000001, 85%, 55%)","hsl(9.755999999999995, 85%, 55%)","hsl(10.091999999999995, 85%, 55%)","hsl(43.199999999999996, 85%, 55%)","hsl(23.604000000000003, 85%, 55%)","hsl(2.5680000000000005, 85%, 55%)","hsl(2.327999999999997, 85%, 55%)","hsl(18.863999999999997, 85%, 55%)","hsl(19.008000000000006, 85%, 55%)","hsl(16.404000000000003, 85%, 55%)","hsl(16.680000000000007, 85%, 55%)","hsl(120, 85%, 55%)","hsl(115.164, 85%, 55%)","hsl(101.01600000000002, 85%, 55%)"],
borderColor: ["hsl(11.051999999999992, 85%, 55%)","hsl(23.723999999999997, 85%, 55%)","hsl(2.280000000000007, 85%, 55%)","hsl(10.848000000000008, 85%, 55%)","hsl(10.5, 85%, 55%)","hsl(9.791999999999996, 85%, 55%)","hsl(8.100000000000001, 85%, 55%)","hsl(9.755999999999995, 85%, 55%)","hsl(10.091999999999995, 85%, 55%)","hsl(43.199999999999996, 85%, 55%)","hsl(23.604000000000003, 85%, 55%)","hsl(2.5680000000000005, 85%, 55%)","hsl(2.327999999999997, 85%, 55%)","hsl(18.863999999999997, 85%, 55%)","hsl(19.008000000000006, 85%, 55%)","hsl(16.404000000000003, 85%, 55%)","hsl(16.680000000000007, 85%, 55%)","hsl(120, 85%, 55%)","hsl(115.164, 85%, 55%)","hsl(101.01600000000002, 85%, 55%)"],
data: [6713,14131,1380,6477,6234,6089,6079,6326,5815,23593,14161,1538,949,6015,10527,8783,8720,60897,61921,58513,9235],
backgroundColor: ["hsl(13.008000000000004, 85%, 55%)","hsl(27.383999999999993, 85%, 55%)","hsl(2.6760000000000046, 85%, 55%)","hsl(12.551999999999992, 85%, 55%)","hsl(12.08399999999999, 85%, 55%)","hsl(11.795999999999998, 85%, 55%)","hsl(11.783999999999992, 85%, 55%)","hsl(12.263999999999998, 85%, 55%)","hsl(11.268, 85%, 55%)","hsl(45.72, 85%, 55%)","hsl(27.444000000000006, 85%, 55%)","hsl(2.976000000000005, 85%, 55%)","hsl(1.8360000000000014, 85%, 55%)","hsl(11.651999999999992, 85%, 55%)","hsl(20.400000000000002, 85%, 55%)","hsl(17.01600000000001, 85%, 55%)","hsl(16.895999999999997, 85%, 55%)","hsl(118.02, 85%, 55%)","hsl(120, 85%, 55%)","hsl(113.39999999999999, 85%, 55%)","hsl(17.891999999999996, 85%, 55%)"],
borderColor: ["hsl(13.008000000000004, 85%, 55%)","hsl(27.383999999999993, 85%, 55%)","hsl(2.6760000000000046, 85%, 55%)","hsl(12.551999999999992, 85%, 55%)","hsl(12.08399999999999, 85%, 55%)","hsl(11.795999999999998, 85%, 55%)","hsl(11.783999999999992, 85%, 55%)","hsl(12.263999999999998, 85%, 55%)","hsl(11.268, 85%, 55%)","hsl(45.72, 85%, 55%)","hsl(27.444000000000006, 85%, 55%)","hsl(2.976000000000005, 85%, 55%)","hsl(1.8360000000000014, 85%, 55%)","hsl(11.651999999999992, 85%, 55%)","hsl(20.400000000000002, 85%, 55%)","hsl(17.01600000000001, 85%, 55%)","hsl(16.895999999999997, 85%, 55%)","hsl(118.02, 85%, 55%)","hsl(120, 85%, 55%)","hsl(113.39999999999999, 85%, 55%)","hsl(17.891999999999996, 85%, 55%)"],
borderWidth: 2,
},
],
Expand Down
136 changes: 71 additions & 65 deletions benchmark/results/general.json
@@ -1,135 +1,141 @@
{
"name": "General performance suite",
"date": "2022-05-13T01:45:51.455Z",
"date": "2022-05-13T03:57:00.626Z",
"version": "1.2.0",
"results": [
{
"name": "Blind cycle a traffic light 500 times by transition",
"ops": 6604,
"margin": 3.5,
"percentSlower": 90.79
"ops": 6713,
"margin": 1.09,
"percentSlower": 89.16
},
{
"name": "Blind cycle a traffic light 500 times by action",
"ops": 14182,
"margin": 1.11,
"percentSlower": 80.23
"ops": 14131,
"margin": 0.96,
"percentSlower": 77.18
},
{
"name": "Blind cycle a basic-hooked traffic light 500 times by transition",
"ops": 1365,
"margin": 0.91,
"percentSlower": 98.1
"ops": 1380,
"margin": 1.01,
"percentSlower": 97.77
},
{
"name": "Blind cycle a named-hooked traffic light 500 times by transition",
"ops": 6480,
"margin": 1.07,
"percentSlower": 90.96
"ops": 6477,
"margin": 1.16,
"percentSlower": 89.54
},
{
"name": "Blind cycle an any-transition traffic light 500 times by transition",
"ops": 6277,
"margin": 1.42,
"percentSlower": 91.25
"ops": 6234,
"margin": 0.94,
"percentSlower": 89.93
},
{
"name": "Blind cycle an exit hooked traffic light 500 times by transition",
"ops": 5853,
"margin": 1.26,
"percentSlower": 91.84
"ops": 6089,
"margin": 1.33,
"percentSlower": 90.17
},
{
"name": "Blind cycle an enter hooked traffic light 500 times by transition",
"ops": 4842,
"margin": 11.16,
"percentSlower": 93.25
"ops": 6079,
"margin": 1.25,
"percentSlower": 90.18
},
{
"name": "Blind cycle a standard-transition hooked light by transition",
"ops": 5833,
"margin": 2.83,
"percentSlower": 91.87
"ops": 6326,
"margin": 1.04,
"percentSlower": 89.78
},
{
"name": "Blind cycle a main-transition hooked light by transition",
"ops": 6031,
"margin": 3.07,
"percentSlower": 91.59
"ops": 5815,
"margin": 5.04,
"percentSlower": 90.61
},
{
"name": "Blind cycle a force-transition hooked light by transition",
"ops": 25819,
"margin": 6.37,
"percentSlower": 64
"ops": 23593,
"margin": 0.71,
"percentSlower": 61.9
},
{
"name": "Blind cycle a traffic light 500 times by action",
"ops": 14108,
"margin": 1.22,
"percentSlower": 80.33
"ops": 14161,
"margin": 2.83,
"percentSlower": 77.13
},
{
"name": "Blind cycle a basic-hooked traffic light 500 times by action",
"ops": 1534,
"margin": 3.21,
"percentSlower": 97.86
"ops": 1538,
"margin": 1.33,
"percentSlower": 97.52
},
{
"name": "Blind cycle a named-hooked traffic light 500 times by action",
"ops": 1393,
"margin": 2.46,
"percentSlower": 98.06
"ops": 949,
"margin": 20.49,
"percentSlower": 98.47
},
{
"name": "Blind cycle an any-action traffic light 500 times by action",
"ops": 11272,
"margin": 2.39,
"percentSlower": 84.28
"ops": 6015,
"margin": 18.96,
"percentSlower": 90.29
},
{
"name": "Blind cycle a global-action traffic light 500 times by action",
"ops": 11357,
"margin": 4.1,
"percentSlower": 84.16
"ops": 10527,
"margin": 5.14,
"percentSlower": 83
},
{
"name": "Blind cycle an exit hooked traffic light 500 times by action",
"ops": 9807,
"margin": 1,
"percentSlower": 86.33
"ops": 8783,
"margin": 2.93,
"percentSlower": 85.82
},
{
"name": "Blind cycle an enter hooked traffic light 500 times by action",
"ops": 9968,
"margin": 1.04,
"percentSlower": 86.1
"ops": 8720,
"margin": 2.28,
"percentSlower": 85.92
},
{
"name": "Blind cycle a standard transition tl 500 times by action",
"ops": 71720,
"margin": 0.84,
"percentSlower": 0
"ops": 60897,
"margin": 5.59,
"percentSlower": 1.65
},
{
"name": "Blind cycle a main transition tl 500 times by action",
"ops": 68833,
"margin": 1.64,
"percentSlower": 4.03
"ops": 61921,
"margin": 5.88,
"percentSlower": 0
},
{
"name": "Blind cycle a forced transition tl 500 times by action",
"ops": 60373,
"margin": 9.04,
"percentSlower": 15.82
"ops": 58513,
"margin": 6.85,
"percentSlower": 5.5
},
{
"name": "Kitchen Sink 500 times",
"ops": 9235,
"margin": 0.83,
"percentSlower": 85.09
}
],
"fastest": {
"name": "Blind cycle a standard transition tl 500 times by action",
"index": 17
"name": "Blind cycle a main transition tl 500 times by action",
"index": 18
},
"slowest": {
"name": "Blind cycle a basic-hooked traffic light 500 times by transition",
"index": 2
"name": "Blind cycle a named-hooked traffic light 500 times by action",
"index": 12
}
}
2 changes: 1 addition & 1 deletion docs/docs/classes/Machine.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/docs/modules.html

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions src/buildjs/benchmark.js
Expand Up @@ -368,6 +368,39 @@ function GlobalActionCycleTLWithNamedHooks500Times() {




const Tl4KS = sm`red 'next' => green 'next' -> yellow 'next' ~> red; [red yellow green] ~> off -> red;`;

Tl4KS.set_hook({ from: 'red', to: 'green', handler: () => true, kind: 'hook' });
Tl4KS.set_hook({ from: 'red', to: 'green', name: 'next', handler: () => true, kind: 'named' });
Tl4KS.set_hook({ from: 'red', to: 'green', name: 'unused', handler: () => true, kind: 'named' });
Tl4KS.set_hook({ handler: () => true, kind: 'any transition' });
Tl4KS.set_hook({ handler: () => true, from: 'red', kind: 'exit' });
Tl4KS.set_hook({ handler: () => true, kind: 'any action' });
Tl4KS.set_hook({ handler: () => true, kind: 'any transition' });
Tl4KS.set_hook({ handler: () => true, kind: 'standard transition' });
Tl4KS.set_hook({ handler: () => true, kind: 'main transition' });
Tl4KS.set_hook({ handler: () => true, kind: 'forced transition' });
Tl4KS.set_hook({ handler: () => true, kind: 'global action' });
Tl4KS.set_hook({ handler: () => true, to: 'red', kind: 'entry' });
Tl4KS.set_hook({ handler: () => true, to: 'red', kind: 'standard transition' });
Tl4KS.set_hook({ handler: () => true, to: 'red', kind: 'main transition' });
Tl4KS.set_hook({ handler: () => true, to: 'red', kind: 'forced transition' });

function KitchenSink500Times() {

for (let i=0; i<500; ++i) {
Tl4GA.transition('green');
Tl4GA.action('next'); // to yellow
Tl4GA.force_transition('red');
}

}





b.suite('General performance suite',

b.add('Blind cycle a traffic light 500 times by transition', TransitionCycleTL500Times ),
Expand All @@ -390,6 +423,7 @@ b.suite('General performance suite',
b.add('Blind cycle a standard transition tl 500 times by action', ActionCycleTLWithSTHooks500Times ),
b.add('Blind cycle a main transition tl 500 times by action', ActionCycleTLWithMTHooks500Times ),
b.add('Blind cycle a forced transition tl 500 times by action', ActionCycleTLWithFTHooks500Times ),
b.add('Kitchen Sink 500 times', KitchenSink500Times ),

b.cycle(),
b.complete(),
Expand Down

0 comments on commit 024f2e2

Please sign in to comment.