Skip to content

Commit

Permalink
Base error object, fixes StoneCypher/fsl#752
Browse files Browse the repository at this point in the history
  • Loading branch information
StoneCypher committed May 15, 2022
1 parent 94a26af commit 9db9bad
Show file tree
Hide file tree
Showing 17 changed files with 177 additions and 86 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="chart1652584461536" width="16" height="9"></canvas>
<canvas id="chart1652624561752" width="16" height="9"></canvas>
</div>
<script>
const format = (num) => {
Expand All @@ -51,18 +51,18 @@
chunked.map((chunk) => chunk.join('')).join(' ') + fractionStr
)
}
const ctx1652584461536 = document
.getElementById('chart1652584461536')
const ctx1652624561752 = document
.getElementById('chart1652624561752')
.getContext('2d')
const chart1652584461536 = new Chart(ctx1652584461536, {
const chart1652624561752 = new Chart(ctx1652624561752, {
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: [7270,14513,1456,6975,6568,6458,6104,6557,6608,25042,14323,1598,1505,11689,11799,10311,9944,62101,68655,68495,9192],
backgroundColor: ["hsl(12.708000000000004, 85%, 55%)","hsl(25.368000000000002, 85%, 55%)","hsl(2.5440000000000054, 85%, 55%)","hsl(12.191999999999997, 85%, 55%)","hsl(11.483999999999993, 85%, 55%)","hsl(11.291999999999994, 85%, 55%)","hsl(10.668000000000001, 85%, 55%)","hsl(11.459999999999997, 85%, 55%)","hsl(11.544000000000006, 85%, 55%)","hsl(43.775999999999996, 85%, 55%)","hsl(25.032, 85%, 55%)","hsl(2.795999999999998, 85%, 55%)","hsl(2.6279999999999974, 85%, 55%)","hsl(20.436, 85%, 55%)","hsl(20.627999999999997, 85%, 55%)","hsl(18.023999999999997, 85%, 55%)","hsl(17.376000000000005, 85%, 55%)","hsl(108.54, 85%, 55%)","hsl(120, 85%, 55%)","hsl(119.72399999999999, 85%, 55%)","hsl(16.068, 85%, 55%)"],
borderColor: ["hsl(12.708000000000004, 85%, 55%)","hsl(25.368000000000002, 85%, 55%)","hsl(2.5440000000000054, 85%, 55%)","hsl(12.191999999999997, 85%, 55%)","hsl(11.483999999999993, 85%, 55%)","hsl(11.291999999999994, 85%, 55%)","hsl(10.668000000000001, 85%, 55%)","hsl(11.459999999999997, 85%, 55%)","hsl(11.544000000000006, 85%, 55%)","hsl(43.775999999999996, 85%, 55%)","hsl(25.032, 85%, 55%)","hsl(2.795999999999998, 85%, 55%)","hsl(2.6279999999999974, 85%, 55%)","hsl(20.436, 85%, 55%)","hsl(20.627999999999997, 85%, 55%)","hsl(18.023999999999997, 85%, 55%)","hsl(17.376000000000005, 85%, 55%)","hsl(108.54, 85%, 55%)","hsl(120, 85%, 55%)","hsl(119.72399999999999, 85%, 55%)","hsl(16.068, 85%, 55%)"],
data: [6904,12502,1256,6663,6256,6092,5537,6037,6349,26128,14044,1610,1469,11312,10920,9914,9639,67892,68500,68153,8966],
backgroundColor: ["hsl(12.095999999999998, 85%, 55%)","hsl(21.9, 85%, 55%)","hsl(2.195999999999998, 85%, 55%)","hsl(11.676000000000005, 85%, 55%)","hsl(10.955999999999994, 85%, 55%)","hsl(10.668000000000001, 85%, 55%)","hsl(9.695999999999998, 85%, 55%)","hsl(10.572000000000003, 85%, 55%)","hsl(11.123999999999995, 85%, 55%)","hsl(45.768, 85%, 55%)","hsl(24.599999999999998, 85%, 55%)","hsl(2.819999999999993, 85%, 55%)","hsl(2.5680000000000005, 85%, 55%)","hsl(19.812000000000005, 85%, 55%)","hsl(19.128, 85%, 55%)","hsl(17.364, 85%, 55%)","hsl(16.883999999999993, 85%, 55%)","hsl(118.932, 85%, 55%)","hsl(120, 85%, 55%)","hsl(119.38799999999999, 85%, 55%)","hsl(15.708000000000006, 85%, 55%)"],
borderColor: ["hsl(12.095999999999998, 85%, 55%)","hsl(21.9, 85%, 55%)","hsl(2.195999999999998, 85%, 55%)","hsl(11.676000000000005, 85%, 55%)","hsl(10.955999999999994, 85%, 55%)","hsl(10.668000000000001, 85%, 55%)","hsl(9.695999999999998, 85%, 55%)","hsl(10.572000000000003, 85%, 55%)","hsl(11.123999999999995, 85%, 55%)","hsl(45.768, 85%, 55%)","hsl(24.599999999999998, 85%, 55%)","hsl(2.819999999999993, 85%, 55%)","hsl(2.5680000000000005, 85%, 55%)","hsl(19.812000000000005, 85%, 55%)","hsl(19.128, 85%, 55%)","hsl(17.364, 85%, 55%)","hsl(16.883999999999993, 85%, 55%)","hsl(118.932, 85%, 55%)","hsl(120, 85%, 55%)","hsl(119.38799999999999, 85%, 55%)","hsl(15.708000000000006, 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-15T03:14:21.536Z",
"date": "2022-05-15T14:22:41.752Z",
"version": "1.2.0",
"results": [
{
"name": "Blind cycle a traffic light 500 times by transition",
"ops": 7270,
"margin": 1.32,
"percentSlower": 89.41
"ops": 6904,
"margin": 1.92,
"percentSlower": 89.92
},
{
"name": "Blind cycle a traffic light 500 times by action",
"ops": 14513,
"margin": 0.53,
"percentSlower": 78.86
"ops": 12502,
"margin": 7.15,
"percentSlower": 81.75
},
{
"name": "Blind cycle a basic-hooked traffic light 500 times by transition",
"ops": 1456,
"margin": 0.89,
"percentSlower": 97.88
"ops": 1256,
"margin": 5.67,
"percentSlower": 98.17
},
{
"name": "Blind cycle a named-hooked traffic light 500 times by transition",
"ops": 6975,
"margin": 1.15,
"percentSlower": 89.84
"ops": 6663,
"margin": 3.16,
"percentSlower": 90.27
},
{
"name": "Blind cycle an any-transition traffic light 500 times by transition",
"ops": 6568,
"margin": 1.9,
"percentSlower": 90.43
"ops": 6256,
"margin": 3.26,
"percentSlower": 90.87
},
{
"name": "Blind cycle an exit hooked traffic light 500 times by transition",
"ops": 6458,
"margin": 0.74,
"percentSlower": 90.59
"ops": 6092,
"margin": 1.48,
"percentSlower": 91.11
},
{
"name": "Blind cycle an enter hooked traffic light 500 times by transition",
"ops": 6104,
"margin": 3.63,
"percentSlower": 91.11
"ops": 5537,
"margin": 6.92,
"percentSlower": 91.92
},
{
"name": "Blind cycle a standard-transition hooked light by transition",
"ops": 6557,
"margin": 0.88,
"percentSlower": 90.45
"ops": 6037,
"margin": 5.72,
"percentSlower": 91.19
},
{
"name": "Blind cycle a main-transition hooked light by transition",
"ops": 6608,
"margin": 0.92,
"percentSlower": 90.38
"ops": 6349,
"margin": 2.27,
"percentSlower": 90.73
},
{
"name": "Blind cycle a force-transition hooked light by transition",
"ops": 25042,
"margin": 0.67,
"percentSlower": 63.52
"ops": 26128,
"margin": 1.07,
"percentSlower": 61.86
},
{
"name": "Blind cycle a traffic light 500 times by action",
"ops": 14323,
"margin": 0.77,
"percentSlower": 79.14
"ops": 14044,
"margin": 2.37,
"percentSlower": 79.5
},
{
"name": "Blind cycle a basic-hooked traffic light 500 times by action",
"ops": 1598,
"margin": 3.15,
"percentSlower": 97.67
"ops": 1610,
"margin": 2.03,
"percentSlower": 97.65
},
{
"name": "Blind cycle a named-hooked traffic light 500 times by action",
"ops": 1505,
"margin": 0.6,
"percentSlower": 97.81
"ops": 1469,
"margin": 0.76,
"percentSlower": 97.86
},
{
"name": "Blind cycle an any-action traffic light 500 times by action",
"ops": 11689,
"margin": 0.95,
"percentSlower": 82.97
"ops": 11312,
"margin": 1.22,
"percentSlower": 83.49
},
{
"name": "Blind cycle a global-action traffic light 500 times by action",
"ops": 11799,
"margin": 0.71,
"percentSlower": 82.81
"ops": 10920,
"margin": 4.62,
"percentSlower": 84.06
},
{
"name": "Blind cycle an exit hooked traffic light 500 times by action",
"ops": 10311,
"margin": 0.91,
"percentSlower": 84.98
"ops": 9914,
"margin": 1.56,
"percentSlower": 85.53
},
{
"name": "Blind cycle an enter hooked traffic light 500 times by action",
"ops": 9944,
"margin": 1.25,
"percentSlower": 85.52
"ops": 9639,
"margin": 2.9,
"percentSlower": 85.93
},
{
"name": "Blind cycle a standard transition tl 500 times by action",
"ops": 62101,
"margin": 2.65,
"percentSlower": 9.55
"ops": 67892,
"margin": 1.37,
"percentSlower": 0.89
},
{
"name": "Blind cycle a main transition tl 500 times by action",
"ops": 68655,
"margin": 0.84,
"ops": 68500,
"margin": 0.94,
"percentSlower": 0
},
{
"name": "Blind cycle a forced transition tl 500 times by action",
"ops": 68495,
"margin": 0.62,
"percentSlower": 0.23
"ops": 68153,
"margin": 1.11,
"percentSlower": 0.51
},
{
"name": "Kitchen Sink 500 times",
"ops": 9192,
"margin": 1.33,
"percentSlower": 86.61
"ops": 8966,
"margin": 2.08,
"percentSlower": 86.91
}
],
"fastest": {
Expand Down
15 changes: 13 additions & 2 deletions dist/es6/jssm.js
@@ -1,10 +1,21 @@
// whargarbl lots of these return arrays could/should be sets
import { reduce as reduce_to_639 } from 'reduce-to-639-1';
import { seq, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key, array_box_if_string, hook_name, named_hook_name } from './jssm_util';
import { parse } from './jssm-dot'; // TODO FIXME WHARGARBL this could be post-typed
import { parse } from './jssm-dot';
import { version } from './version'; // replaced from package.js in build
class JssmError extends Error {
constructor(machine, message) {
super(message);
this.name = 'JssmError';
}
}
;
function xthrow(machine, message) {
throw new Error(`${(machine.instance_name !== undefined) ? `[[${machine.instance_name}]]: ` : ''}${message}${machine.state !== undefined ? ` (at ${machine.state})` : ''}`);
throw new JssmError(this, `${(machine.instance_name !== undefined)
? `[[${machine.instance_name}]]: `
: ''}${message}${machine.state !== undefined
? ` (at ${machine.state})`
: ''}`);
}
/* eslint-disable complexity */
function arrow_direction(arrow) {
Expand Down
4 changes: 4 additions & 0 deletions dist/es6/jssm_error.d.ts
@@ -0,0 +1,4 @@
declare class JssmError extends Error {
constructor(machine: any, message: string);
}
export { JssmError };
8 changes: 8 additions & 0 deletions dist/es6/jssm_error.js
@@ -0,0 +1,8 @@
class JssmError extends Error {
constructor(machine, message) {
super(message);
this.name = 'JssmError';
}
}
;
export { JssmError };
2 changes: 1 addition & 1 deletion dist/es6/version.js
@@ -1,2 +1,2 @@
const version = "5.62.0";
const version = "5.63.0";
export { version };
2 changes: 1 addition & 1 deletion dist/jssm.es5.cjs.js

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions dist/jssm.es5.cjs.nonmin.js
Expand Up @@ -15886,11 +15886,21 @@ function peg$parse(input, options) {
}
}

const version = "5.62.0";
const version = "5.63.0";

// whargarbl lots of these return arrays could/should be sets
class JssmError extends Error {
constructor(machine, message) {
super(message);
this.name = 'JssmError';
}
}
function xthrow(machine, message) {
throw new Error(`${(machine.instance_name !== undefined) ? `[[${machine.instance_name}]]: ` : ''}${message}${machine.state !== undefined ? ` (at ${machine.state})` : ''}`);
throw new JssmError(this, `${(machine.instance_name !== undefined)
? `[[${machine.instance_name}]]: `
: ''}${message}${machine.state !== undefined
? ` (at ${machine.state})`
: ''}`);
}
/* eslint-disable complexity */
function arrow_direction(arrow) {
Expand Down
2 changes: 1 addition & 1 deletion dist/jssm.es5.iife.js

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions dist/jssm.es5.iife.nonmin.js
Expand Up @@ -15885,11 +15885,21 @@ var jssm = (function (exports) {
}
}

const version = "5.62.0";
const version = "5.63.0";

// whargarbl lots of these return arrays could/should be sets
class JssmError extends Error {
constructor(machine, message) {
super(message);
this.name = 'JssmError';
}
}
function xthrow(machine, message) {
throw new Error(`${(machine.instance_name !== undefined) ? `[[${machine.instance_name}]]: ` : ''}${message}${machine.state !== undefined ? ` (at ${machine.state})` : ''}`);
throw new JssmError(this, `${(machine.instance_name !== undefined)
? `[[${machine.instance_name}]]: `
: ''}${message}${machine.state !== undefined
? ` (at ${machine.state})`
: ''}`);
}
/* eslint-disable complexity */
function arrow_direction(arrow) {
Expand Down
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.

4 changes: 4 additions & 0 deletions jssm_error.d.ts
@@ -0,0 +1,4 @@
declare class JssmError extends Error {
constructor(machine: any, message: string);
}
export { JssmError };
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "jssm",
"version": "5.62.0",
"version": "5.63.0",
"engines": {
"node": ">=10.0.0"
},
Expand Down
33 changes: 30 additions & 3 deletions src/ts/jssm.ts
Expand Up @@ -37,16 +37,43 @@ import {



import { parse } from './jssm-dot'; // TODO FIXME WHARGARBL this could be post-typed
import { parse } from './jssm-dot';
import { version } from './version'; // replaced from package.js in build

import { version } from './version'; // replaced from package.js in build




class JssmError<mDT> extends Error {

constructor(machine: Machine<mDT>, message: string) {

super(message);
this.name = 'JssmError';

}

};





function xthrow<mDT>(machine: Machine<mDT>, message): never {
throw new Error(`${(machine.instance_name !== undefined)? `[[${machine.instance_name}]]: ` : ''}${message}${machine.state !== undefined? ` (at ${machine.state})` : ''}`);

throw new JssmError( this,
`${
(machine.instance_name !== undefined)
? `[[${machine.instance_name}]]: `
: ''
}${
message
}${
machine.state !== undefined
? ` (at ${machine.state})`
: ''
}`);

}


Expand Down
17 changes: 17 additions & 0 deletions src/ts/jssm_error.ts
@@ -0,0 +1,17 @@

class JssmError extends Error {

constructor(machine: any, message: string) {

super(message);
this.name = 'JssmError';

}

};





export { JssmError };

0 comments on commit 9db9bad

Please sign in to comment.