Skip to content

Commit

Permalink
Merge pull request #479 from StoneCypher/MoreDocumentation
Browse files Browse the repository at this point in the history
Document make, compile, transfer_state_properties, compile_rule_handler, compile_rule_handle_transition, compile_rule_transition_step
  • Loading branch information
StoneCypher committed May 22, 2022
2 parents 0fd6005 + 539f203 commit eac57da
Show file tree
Hide file tree
Showing 15 changed files with 852 additions and 97 deletions.
14 changes: 7 additions & 7 deletions benchmark/results/general.chart.html
Expand Up @@ -28,7 +28,7 @@
</head>
<body>
<div class="container">
<canvas id="chart1653226749814" width="16" height="9"></canvas>
<canvas id="chart1653229181730" width="16" height="9"></canvas>
</div>
<script>
const format = (num) => {
Expand All @@ -51,18 +51,18 @@
chunked.map((chunk) => chunk.join('')).join(' ') + fractionStr
)
}
const ctx1653226749814 = document
.getElementById('chart1653226749814')
const ctx1653229181730 = document
.getElementById('chart1653229181730')
.getContext('2d')
const chart1653226749814 = new Chart(ctx1653226749814, {
const chart1653229181730 = new Chart(ctx1653229181730, {
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","Kitchen Sink 500 times"],
datasets: [
{
data: [4737,11565,1315,6401,5912,5838,5810,6112,5183,21664,13037,1558,1357,9430,10970,8558,8697,66884,67491,63318,8427],
backgroundColor: ["hsl(8.423999999999994, 85%, 55%)","hsl(20.567999999999998, 85%, 55%)","hsl(2.3400000000000034, 85%, 55%)","hsl(11.376000000000005, 85%, 55%)","hsl(10.512000000000006, 85%, 55%)","hsl(10.380000000000008, 85%, 55%)","hsl(10.331999999999999, 85%, 55%)","hsl(10.872000000000003, 85%, 55%)","hsl(9.216000000000008, 85%, 55%)","hsl(38.519999999999996, 85%, 55%)","hsl(23.18399999999999, 85%, 55%)","hsl(2.772000000000003, 85%, 55%)","hsl(2.412000000000006, 85%, 55%)","hsl(16.764, 85%, 55%)","hsl(19.5, 85%, 55%)","hsl(15.21600000000001, 85%, 55%)","hsl(15.468000000000002, 85%, 55%)","hsl(118.92, 85%, 55%)","hsl(120, 85%, 55%)","hsl(112.58399999999999, 85%, 55%)","hsl(14.987999999999994, 85%, 55%)"],
borderColor: ["hsl(8.423999999999994, 85%, 55%)","hsl(20.567999999999998, 85%, 55%)","hsl(2.3400000000000034, 85%, 55%)","hsl(11.376000000000005, 85%, 55%)","hsl(10.512000000000006, 85%, 55%)","hsl(10.380000000000008, 85%, 55%)","hsl(10.331999999999999, 85%, 55%)","hsl(10.872000000000003, 85%, 55%)","hsl(9.216000000000008, 85%, 55%)","hsl(38.519999999999996, 85%, 55%)","hsl(23.18399999999999, 85%, 55%)","hsl(2.772000000000003, 85%, 55%)","hsl(2.412000000000006, 85%, 55%)","hsl(16.764, 85%, 55%)","hsl(19.5, 85%, 55%)","hsl(15.21600000000001, 85%, 55%)","hsl(15.468000000000002, 85%, 55%)","hsl(118.92, 85%, 55%)","hsl(120, 85%, 55%)","hsl(112.58399999999999, 85%, 55%)","hsl(14.987999999999994, 85%, 55%)"],
data: [5701,13401,1267,6011,5885,5992,6010,6244,5639,28217,14110,1506,1341,10736,10142,8748,8607,62153,62285,53459,8986],
backgroundColor: ["hsl(10.980000000000006, 85%, 55%)","hsl(25.823999999999995, 85%, 55%)","hsl(2.4360000000000017, 85%, 55%)","hsl(11.580000000000007, 85%, 55%)","hsl(11.340000000000003, 85%, 55%)","hsl(11.544000000000006, 85%, 55%)","hsl(11.580000000000007, 85%, 55%)","hsl(12.023999999999994, 85%, 55%)","hsl(10.859999999999996, 85%, 55%)","hsl(54.35999999999999, 85%, 55%)","hsl(27.180000000000007, 85%, 55%)","hsl(2.904000000000002, 85%, 55%)","hsl(2.5800000000000067, 85%, 55%)","hsl(20.68799999999999, 85%, 55%)","hsl(19.536, 85%, 55%)","hsl(16.859999999999996, 85%, 55%)","hsl(16.583999999999993, 85%, 55%)","hsl(119.748, 85%, 55%)","hsl(120, 85%, 55%)","hsl(102.996, 85%, 55%)","hsl(17.31600000000001, 85%, 55%)"],
borderColor: ["hsl(10.980000000000006, 85%, 55%)","hsl(25.823999999999995, 85%, 55%)","hsl(2.4360000000000017, 85%, 55%)","hsl(11.580000000000007, 85%, 55%)","hsl(11.340000000000003, 85%, 55%)","hsl(11.544000000000006, 85%, 55%)","hsl(11.580000000000007, 85%, 55%)","hsl(12.023999999999994, 85%, 55%)","hsl(10.859999999999996, 85%, 55%)","hsl(54.35999999999999, 85%, 55%)","hsl(27.180000000000007, 85%, 55%)","hsl(2.904000000000002, 85%, 55%)","hsl(2.5800000000000067, 85%, 55%)","hsl(20.68799999999999, 85%, 55%)","hsl(19.536, 85%, 55%)","hsl(16.859999999999996, 85%, 55%)","hsl(16.583999999999993, 85%, 55%)","hsl(119.748, 85%, 55%)","hsl(120, 85%, 55%)","hsl(102.996, 85%, 55%)","hsl(17.31600000000001, 85%, 55%)"],
borderWidth: 2,
},
],
Expand Down
126 changes: 63 additions & 63 deletions benchmark/results/general.json
@@ -1,133 +1,133 @@
{
"name": "General performance suite",
"date": "2022-05-22T13:39:09.814Z",
"date": "2022-05-22T14:19:41.730Z",
"version": "1.2.0",
"results": [
{
"name": "Blind cycle a traffic light 500 times by transition",
"ops": 4737,
"margin": 9.49,
"percentSlower": 92.98
"ops": 5701,
"margin": 1.73,
"percentSlower": 90.85
},
{
"name": "Blind cycle a traffic light 500 times by action",
"ops": 11565,
"margin": 6.71,
"percentSlower": 82.86
"ops": 13401,
"margin": 2.31,
"percentSlower": 78.48
},
{
"name": "Blind cycle a basic-hooked traffic light 500 times by transition",
"ops": 1315,
"margin": 4.44,
"percentSlower": 98.05
"ops": 1267,
"margin": 6.55,
"percentSlower": 97.97
},
{
"name": "Blind cycle a named-hooked traffic light 500 times by transition",
"ops": 6401,
"margin": 1.25,
"percentSlower": 90.52
"ops": 6011,
"margin": 7.53,
"percentSlower": 90.35
},
{
"name": "Blind cycle an any-transition traffic light 500 times by transition",
"ops": 5912,
"margin": 2.31,
"percentSlower": 91.24
"ops": 5885,
"margin": 2.9,
"percentSlower": 90.55
},
{
"name": "Blind cycle an exit hooked traffic light 500 times by transition",
"ops": 5838,
"margin": 1.11,
"percentSlower": 91.35
"ops": 5992,
"margin": 1.29,
"percentSlower": 90.38
},
{
"name": "Blind cycle an enter hooked traffic light 500 times by transition",
"ops": 5810,
"margin": 1.33,
"percentSlower": 91.39
"ops": 6010,
"margin": 1.18,
"percentSlower": 90.35
},
{
"name": "Blind cycle a standard-transition hooked light by transition",
"ops": 6112,
"margin": 0.57,
"percentSlower": 90.94
"ops": 6244,
"margin": 0.82,
"percentSlower": 89.98
},
{
"name": "Blind cycle a main-transition hooked light by transition",
"ops": 5183,
"margin": 9.28,
"percentSlower": 92.32
"ops": 5639,
"margin": 7.84,
"percentSlower": 90.95
},
{
"name": "Blind cycle a force-transition hooked light by transition",
"ops": 21664,
"margin": 3.17,
"percentSlower": 67.9
"ops": 28217,
"margin": 2.53,
"percentSlower": 54.7
},
{
"name": "Blind cycle a traffic light 500 times by action",
"ops": 13037,
"margin": 3.54,
"percentSlower": 80.68
"ops": 14110,
"margin": 0.69,
"percentSlower": 77.35
},
{
"name": "Blind cycle a basic-hooked traffic light 500 times by action",
"ops": 1558,
"margin": 1.63,
"percentSlower": 97.69
"ops": 1506,
"margin": 6.16,
"percentSlower": 97.58
},
{
"name": "Blind cycle a named-hooked traffic light 500 times by action",
"ops": 1357,
"margin": 0.97,
"percentSlower": 97.99
"ops": 1341,
"margin": 5.11,
"percentSlower": 97.85
},
{
"name": "Blind cycle an any-action traffic light 500 times by action",
"ops": 9430,
"margin": 10.93,
"percentSlower": 86.03
"ops": 10736,
"margin": 1.13,
"percentSlower": 82.76
},
{
"name": "Blind cycle a global-action traffic light 500 times by action",
"ops": 10970,
"margin": 1.73,
"percentSlower": 83.75
"ops": 10142,
"margin": 5.76,
"percentSlower": 83.72
},
{
"name": "Blind cycle an exit hooked traffic light 500 times by action",
"ops": 8558,
"margin": 8.61,
"percentSlower": 87.32
"ops": 8748,
"margin": 6.73,
"percentSlower": 85.95
},
{
"name": "Blind cycle an enter hooked traffic light 500 times by action",
"ops": 8697,
"margin": 0.68,
"percentSlower": 87.11
"ops": 8607,
"margin": 8.46,
"percentSlower": 86.18
},
{
"name": "Blind cycle a standard transition tl 500 times by action",
"ops": 66884,
"margin": 0.76,
"percentSlower": 0.9
"ops": 62153,
"margin": 1.29,
"percentSlower": 0.21
},
{
"name": "Blind cycle a main transition tl 500 times by action",
"ops": 67491,
"margin": 0.63,
"ops": 62285,
"margin": 0.92,
"percentSlower": 0
},
{
"name": "Blind cycle a forced transition tl 500 times by action",
"ops": 63318,
"margin": 0.68,
"percentSlower": 6.18
"ops": 53459,
"margin": 8.74,
"percentSlower": 14.17
},
{
"name": "Kitchen Sink 500 times",
"ops": 8427,
"margin": 7.56,
"percentSlower": 87.51
"ops": 8986,
"margin": 2.37,
"percentSlower": 85.57
}
],
"fastest": {
Expand Down
108 changes: 106 additions & 2 deletions dist/es6/jssm.d.ts
Expand Up @@ -51,13 +51,117 @@ declare function arrow_left_kind(arrow: JssmArrow): JssmArrowKind;
declare function arrow_right_kind(arrow: JssmArrow): JssmArrowKind;
/*********
*
* Internal convenience method for alting out an object as the options call.
* Not generally meant for external use.
* This method wraps the parser call that comes from the peg grammar,
* {@link parse}. Generally neither this nor that should be used directly
* unless you mean to develop plugins or extensions for the machine.
*
* Parses the intermediate representation of a compiled string down to a
* machine configuration object. If you're using this (probably don't,) you're
* probably also using {@link compile} and {@link Machine.constructor}.
*
* ```typescript
* import { parse, compile, Machine } from './jssm';
*
* const intermediate = wrap_parse('a -> b;', {});
* // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
*
* const cfg = compile(intermediate);
* // { start_states:['a'], transitions: [{ from:'a', to:'b', kind:'legal', forced_only:false, main_path:false }] }
*
* const machine = new Machine(cfg);
* // Machine { _instance_name: undefined, _state: 'a', ...
* ```
*
* This method is mostly for plugin and intermediate tool authors, or people
* who need to work with the machine's intermediate representation.
*
* # Hey!
*
* Most people looking at this want either the `sm` operator or method `from`,
* which perform all the steps in the chain. The library's author mostly uses
* operator `sm`, and mostly falls back to `.from` when needing to parse
* strings dynamically instead of from template literals.
*
* ```typescript
* import { sm } from './jssm';
*
* const switch = sm`on <=> off;`;
* ```
*
* &hellip; or &hellip;
*
* ```typescript
* import * as jssm from './jssm';
*
* const toggle = jssm.from('up <=> down;');
* ```
*
* `wrap_parse` itself is an internal convenience method for alting out an
* object as the options call. Not generally meant for external use.
*
*/
declare function wrap_parse(input: string, options?: Object): any;
/*********
*
* Compile a machine's JSON intermediate representation to a config object. If
* you're using this (probably don't,) you're probably also using
* {@link parse} to get the IR, and the object constructor
* {@link Machine.construct} to turn the config object into a workable machine.
*
* ```typescript
* import { parse, compile, Machine } from './jssm';
*
* const intermediate = parse('a -> b;');
* // [ {key:'transition', from:'a', se:{kind:'->',to:'b'}} ]
*
* const cfg = compile(intermediate);
* // { start_states:['a'], transitions: [{ from:'a', to:'b', kind:'legal', forced_only:false, main_path:false }] }
*
* const machine = new Machine(cfg);
* // Machine { _instance_name: undefined, _state: 'a', ...
* ```
*
* This method is mostly for plugin and intermediate tool authors, or people
* who need to work with the machine's intermediate representation.
*
* # Hey!
*
* Most people looking at this want either the `sm` operator or method `from`,
* which perform all the steps in the chain. The library's author mostly uses
* operator `sm`, and mostly falls back to `.from` when needing to parse
* strings dynamically instead of from template literals.
*
* ```typescript
* import { sm } from './jssm';
*
* const switch = sm`on <=> off;`;
* ```
*
* &hellip; or &hellip;
*
* ```typescript
* import * as jssm from './jssm';
*
* const toggle = jssm.from('up <=> down;');
* ```
*
*/
declare function compile<mDT>(tree: JssmParseTree): JssmGenericConfig<mDT>;
/*********
*
* An internal convenience wrapper for parsing then compiling a machine string.
* Not generally meant for external use. Please see {@link compile} or
* {@link sm}.
*
*/
declare function make<mDT>(plan: string): JssmGenericConfig<mDT>;
/*********
*
* An internal method meant to take a series of declarations and fold them into
* a single multi-faceted declaration, in the process of building a state. Not
* generally meant for external use.
*
*/
declare function transfer_state_properties(state_decl: JssmStateDeclaration): JssmStateDeclaration;
declare class Machine<mDT> {
_state: StateType;
Expand Down

0 comments on commit eac57da

Please sign in to comment.