porffor 0.49.1 → 0.49.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/compiler/2c.js CHANGED
@@ -343,7 +343,7 @@ export default ({ funcs, globals, tags, data, exceptions, pages }) => {
343
343
  const typedReturns = f.returnType == null;
344
344
 
345
345
  const shouldInline = false; // f.internal;
346
- if (f.name === 'main') out += `int main(${prependMain.has('argv') ? 'int argc, char* argv[]' : ''}) {\n`;
346
+ if (f.name === '#main') out += `int main(${prependMain.has('argv') ? 'int argc, char* argv[]' : ''}) {\n`;
347
347
  else out += `${!typedReturns ? (returns ? CValtype[f.returns[0]] : 'void') : 'struct ReturnValue'} ${shouldInline ? 'inline ' : ''}${sanitize(f.name)}(${f.params.map((x, i) => `${CValtype[x]} ${invLocals[i]}`).join(', ')}) {\n`;
348
348
 
349
349
  if (f.name === '__Porffor_promise_runJobs') {
@@ -352,7 +352,7 @@ export default ({ funcs, globals, tags, data, exceptions, pages }) => {
352
352
  return;
353
353
  }
354
354
 
355
- if (f.name === 'main') {
355
+ if (f.name === '#main') {
356
356
  out += ' ' + [...prependMain.values()].join('\n ');
357
357
  if (prependMain.size > 0) out += '\n\n';
358
358
  }
@@ -881,7 +881,7 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
881
881
  line(`return ${vals.pop()}`);
882
882
  }
883
883
 
884
- if (f.name === 'main') {
884
+ if (f.name === '#main') {
885
885
  out += '\n';
886
886
  line(`return 0`);
887
887
  }
@@ -891,14 +891,14 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
891
891
  globalThis.out = globalThis.out + out;
892
892
  };
893
893
 
894
- cify(funcs.find(x => x.name === 'main'));
894
+ cify(funcs.find(x => x.name === '#main'));
895
895
 
896
896
  const rawParams = f => {
897
897
  if (ffiFuncs[f.name]) return ffiFuncs[f.name].parameters;
898
898
  return f.params;
899
899
  };
900
900
 
901
- prepend.set('func decls', funcs.filter(x => x.name !== 'main' && cified.has(x.name)).map(f => {
901
+ prepend.set('func decls', funcs.filter(x => x.name !== '#main' && cified.has(x.name)).map(f => {
902
902
  const returns = f.returns.length > 0;
903
903
  const typedReturns = f.returnType == null;
904
904
 
@@ -8,7 +8,7 @@ const pagePtr = ind => {
8
8
 
9
9
  export const nameToReason = (scope, name) => {
10
10
  let scopeName = scope.name;
11
- if (globalThis.precompile && scopeName === 'main') scopeName = globalThis.precompile;
11
+ if (globalThis.precompile && scopeName === '#main') scopeName = globalThis.precompile;
12
12
 
13
13
  return `${Prefs.scopedPageNames ? (scopeName + '/') : ''}${name}`;
14
14
  };
@@ -226,7 +226,7 @@ export default (funcs, globals, tags, pages, data, noTreeshake = false) => {
226
226
  );
227
227
  time('memory section');
228
228
 
229
- const exports = funcs.filter(x => x.export).map((x, i) => [ ...encodeString(x.name === 'main' ? 'm' : x.name), ExportDesc.func, ...unsignedLEB128(x.asmIndex) ]);
229
+ const exports = funcs.filter(x => x.export).map((x, i) => [ ...encodeString(x.name === '#main' ? 'm' : x.name), ExportDesc.func, ...unsignedLEB128(x.asmIndex) ]);
230
230
 
231
231
  // export memory if used
232
232
  if (usesMemory) exports.unshift([ ...encodeString('$'), ExportDesc.mem, 0x00 ]);
@@ -406,7 +406,7 @@ const generateIdent = (scope, decl) => {
406
406
  }
407
407
 
408
408
  if (local?.idx === undefined) {
409
- if (name === 'arguments' && scope.name !== 'main' && !scope.arrow) {
409
+ if (name === 'arguments' && scope.name !== '#main' && !scope.arrow) {
410
410
  // todo: not compliant
411
411
  let len = countLength(scope);
412
412
  const names = new Array(len);
@@ -1352,7 +1352,7 @@ const getType = (scope, name, failEarly = false) => {
1352
1352
  return fallback;
1353
1353
  }
1354
1354
 
1355
- if (name === 'arguments' && scope.name !== 'main' && !scope.arrow) {
1355
+ if (name === 'arguments' && scope.name !== '#main' && !scope.arrow) {
1356
1356
  return number(TYPES.array, Valtype.i32);
1357
1357
  }
1358
1358
 
@@ -3075,14 +3075,13 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
3075
3075
  }
3076
3076
  }
3077
3077
 
3078
- const topLevel = scope.name === 'main';
3079
-
3080
3078
  if (typeof pattern === 'string') {
3081
3079
  pattern = { type: 'Identifier', name: pattern };
3082
3080
  }
3083
3081
 
3084
3082
  // todo: handle globalThis.foo = ...
3085
3083
 
3084
+ const topLevel = scope.name === '#main';
3086
3085
  if (pattern.type === 'Identifier') {
3087
3086
  let out = [];
3088
3087
  const name = pattern.name;
@@ -3314,7 +3313,7 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
3314
3313
  const generateVar = (scope, decl) => {
3315
3314
  let out = [];
3316
3315
 
3317
- const topLevel = scope.name === 'main';
3316
+ const topLevel = scope.name === '#main';
3318
3317
 
3319
3318
  // global variable if in top scope (main) or if internally wanted
3320
3319
  const global = decl._global ?? (topLevel || decl._bare);
@@ -4175,7 +4174,7 @@ const generateForOf = (scope, decl) => {
4175
4174
  setVar = generateVarDstr(scope, 'var', decl.left, { type: 'Identifier', name: tmpName }, undefined, true);
4176
4175
  } else {
4177
4176
  // todo: verify this is correct
4178
- const global = scope.name === 'main' && decl.left.kind === 'var';
4177
+ const global = scope.name === '#main' && decl.left.kind === 'var';
4179
4178
  setVar = generateVarDstr(scope, decl.left.kind, decl.left?.declarations?.[0]?.id ?? decl.left, { type: 'Identifier', name: tmpName }, undefined, global);
4180
4179
  }
4181
4180
 
@@ -4537,7 +4536,7 @@ const generateForIn = (scope, decl) => {
4537
4536
  setVar = generateVarDstr(scope, 'var', decl.left, { type: 'Identifier', name: tmpName }, undefined, true);
4538
4537
  } else {
4539
4538
  // todo: verify this is correct
4540
- const global = scope.name === 'main' && decl.left.kind === 'var';
4539
+ const global = scope.name === '#main' && decl.left.kind === 'var';
4541
4540
  setVar = generateVarDstr(scope, decl.left.kind, decl.left?.declarations?.[0]?.id ?? decl.left, { type: 'Identifier', name: tmpName }, undefined, global);
4542
4541
  }
4543
4542
 
@@ -6245,7 +6244,7 @@ const generateFunc = (scope, decl, forceNoExpr = false) => {
6245
6244
  ensureTag();
6246
6245
  }
6247
6246
 
6248
- if (name === 'main') {
6247
+ if (name === '#main') {
6249
6248
  func.gotLastType = true;
6250
6249
  func.export = true;
6251
6250
 
@@ -6358,7 +6357,7 @@ const generateFunc = (scope, decl, forceNoExpr = false) => {
6358
6357
  func.jsLength = jsLength;
6359
6358
 
6360
6359
  // force generate for main
6361
- if (name === 'main') func.generate();
6360
+ if (name === '#main') func.generate();
6362
6361
 
6363
6362
  // force generate all for precompile
6364
6363
  if (globalThis.precompile) func.generate();
@@ -6537,7 +6536,7 @@ export default program => {
6537
6536
  const getObjectName = x => x.startsWith('__') && x.slice(2, x.indexOf('_', 2));
6538
6537
  objectHackers = ['assert', 'compareArray', 'Test262Error', ...new Set(Object.keys(builtinFuncs).map(getObjectName).concat(Object.keys(builtinVars).map(getObjectName)).filter(x => x))];
6539
6538
 
6540
- program.id = { name: 'main' };
6539
+ program.id = { name: '#main' };
6541
6540
 
6542
6541
  program.body = {
6543
6542
  type: 'BlockStatement',
package/compiler/pgo.js CHANGED
@@ -214,7 +214,7 @@ export const run = obj => {
214
214
  log = '';
215
215
  for (const x of funcs) {
216
216
  // skip pgo opt for main()
217
- if (x.name === 'main') continue;
217
+ if (x.name === '#main') continue;
218
218
 
219
219
  const wasmFunc = wasmFuncs.find(y => y.name === x.name);
220
220
 
@@ -70,8 +70,8 @@ const compile = async (file, _funcs) => {
70
70
  return acc;
71
71
  }, {});
72
72
 
73
- const main = funcs.find(x => x.name === 'main');
74
- const exports = funcs.filter(x => x.export && x.name !== 'main');
73
+ const main = funcs.find(x => x.name === '#main');
74
+ const exports = funcs.filter(x => x.export && x.name !== '#main');
75
75
  for (const x of exports) {
76
76
  if (x.data) {
77
77
  x.data = x.data.reduce((acc, x) => { acc[data[x].page] = data[x].bytes; return acc; }, {});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
4
- "version": "0.49.1",
4
+ "version": "0.49.3",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/richards.js ADDED
@@ -0,0 +1,951 @@
1
+ // Copyright 2013 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ // Performance.now is used in latency benchmarks, the fallback is Date.now.
29
+ var performance = performance || {};
30
+ performance.now = (function () {
31
+ return (
32
+ performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || Date.now
33
+ );
34
+ })();
35
+
36
+ // Simple framework for running the benchmark suites and
37
+ // computing a score based on the timing measurements.
38
+
39
+ // A benchmark has a name (string) and a function that will be run to
40
+ // do the performance measurement. The optional setup and tearDown
41
+ // arguments are functions that will be invoked before and after
42
+ // running the benchmark, but the running time of these functions will
43
+ // not be accounted for in the benchmark score.
44
+ function Benchmark(
45
+ name,
46
+ doWarmup,
47
+ doDeterministic,
48
+ deterministicIterations,
49
+ run,
50
+ setup,
51
+ tearDown,
52
+ rmsResult,
53
+ minIterations
54
+ ) {
55
+ this.name = name;
56
+ this.doWarmup = doWarmup;
57
+ this.doDeterministic = doDeterministic;
58
+ this.deterministicIterations = deterministicIterations;
59
+ this.run = run;
60
+ this.Setup = setup ? setup : function () {};
61
+ this.TearDown = tearDown ? tearDown : function () {};
62
+ this.rmsResult = rmsResult ? rmsResult : null;
63
+ this.minIterations = minIterations ? minIterations : 32;
64
+ }
65
+
66
+ // Benchmark results hold the benchmark and the measured time used to
67
+ // run the benchmark. The benchmark score is computed later once a
68
+ // full benchmark suite has run to completion. If latency is set to 0
69
+ // then there is no latency score for this benchmark.
70
+ function BenchmarkResult(benchmark, time, latency) {
71
+ this.benchmark = benchmark;
72
+ this.time = time;
73
+ this.latency = latency;
74
+ }
75
+
76
+ // Automatically convert results to numbers. Used by the geometric
77
+ // mean computation.
78
+ BenchmarkResult.prototype.valueOf = function () {
79
+ return this.time;
80
+ };
81
+
82
+ // Suites of benchmarks consist of a name and the set of benchmarks in
83
+ // addition to the reference timing that the final score will be based
84
+ // on. This way, all scores are relative to a reference run and higher
85
+ // scores implies better performance.
86
+ function BenchmarkSuite(name, reference, benchmarks) {
87
+ this.name = name;
88
+ this.reference = reference;
89
+ this.benchmarks = benchmarks;
90
+ BenchmarkSuite.suites.push(this);
91
+ }
92
+
93
+ // Keep track of all declared benchmark suites.
94
+ BenchmarkSuite.suites = [];
95
+
96
+ // Scores are not comparable across versions. Bump the version if
97
+ // you're making changes that will affect that scores, e.g. if you add
98
+ // a new benchmark or change an existing one.
99
+ BenchmarkSuite.version = "9";
100
+
101
+ // Defines global benchsuite running mode that overrides benchmark suite
102
+ // behavior. Intended to be set by the benchmark driver. Undefined
103
+ // values here allow a benchmark to define behaviour itself.
104
+ BenchmarkSuite.config = {
105
+ doWarmup: undefined,
106
+ doDeterministic: undefined,
107
+ };
108
+
109
+ // To make the benchmark results predictable, we replace Math.random
110
+ // with a 100% deterministic alternative.
111
+ BenchmarkSuite.ResetRNG = function () {
112
+ Math.random = (function () {
113
+ var seed = 49734321;
114
+ return function () {
115
+ // Robert Jenkins' 32 bit integer hash function.
116
+ seed = (seed + 0x7ed55d16 + (seed << 12)) & 0xffffffff;
117
+ seed = (seed ^ 0xc761c23c ^ (seed >>> 19)) & 0xffffffff;
118
+ seed = (seed + 0x165667b1 + (seed << 5)) & 0xffffffff;
119
+ seed = ((seed + 0xd3a2646c) ^ (seed << 9)) & 0xffffffff;
120
+ seed = (seed + 0xfd7046c5 + (seed << 3)) & 0xffffffff;
121
+ seed = (seed ^ 0xb55a4f09 ^ (seed >>> 16)) & 0xffffffff;
122
+ return (seed & 0xfffffff) / 0x10000000;
123
+ };
124
+ })();
125
+ };
126
+
127
+ // Runs all registered benchmark suites and optionally yields between
128
+ // each individual benchmark to avoid running for too long in the
129
+ // context of browsers. Once done, the final score is reported to the
130
+ // runner.
131
+ BenchmarkSuite.RunSuites = function (runner, skipBenchmarks) {
132
+ skipBenchmarks = typeof skipBenchmarks === "undefined" ? [] : skipBenchmarks;
133
+ var continuation = null;
134
+ var suites = BenchmarkSuite.suites;
135
+ var length = suites.length;
136
+ BenchmarkSuite.scores = [];
137
+ var index = 0;
138
+ function RunStep() {
139
+ while (continuation || index < length) {
140
+ if (continuation) {
141
+ continuation = continuation();
142
+ } else {
143
+ var suite = suites[index++];
144
+ if (runner.NotifyStart) runner.NotifyStart(suite.name);
145
+ if (skipBenchmarks.indexOf(suite.name) > -1) {
146
+ suite.NotifySkipped(runner);
147
+ } else {
148
+ continuation = suite.RunStep(runner);
149
+ }
150
+ }
151
+ if (continuation && typeof window != "undefined" && window.setTimeout) {
152
+ window.setTimeout(RunStep, 25);
153
+ return;
154
+ }
155
+ }
156
+
157
+ // show final result
158
+ if (runner.NotifyScore) {
159
+ var score = BenchmarkSuite.GeometricMean(BenchmarkSuite.scores);
160
+ var formatted = BenchmarkSuite.FormatScore(100 * score);
161
+ runner.NotifyScore(formatted);
162
+ }
163
+ }
164
+ RunStep();
165
+ };
166
+
167
+ // Counts the total number of registered benchmarks. Useful for
168
+ // showing progress as a percentage.
169
+ BenchmarkSuite.CountBenchmarks = function () {
170
+ var result = 0;
171
+ var suites = BenchmarkSuite.suites;
172
+ for (var i = 0; i < suites.length; i++) {
173
+ result += suites[i].benchmarks.length;
174
+ }
175
+ return result;
176
+ };
177
+
178
+ // Computes the geometric mean of a set of numbers.
179
+ BenchmarkSuite.GeometricMean = function (numbers) {
180
+ var log = 0;
181
+ for (var i = 0; i < numbers.length; i++) {
182
+ log += Math.log(numbers[i]);
183
+ }
184
+ return Math.pow(Math.E, log / numbers.length);
185
+ };
186
+
187
+ // Computes the geometric mean of a set of throughput time measurements.
188
+ BenchmarkSuite.GeometricMeanTime = function (measurements) {
189
+ var log = 0;
190
+ for (var i = 0; i < measurements.length; i++) {
191
+ log += Math.log(measurements[i].time);
192
+ }
193
+ return Math.pow(Math.E, log / measurements.length);
194
+ };
195
+
196
+ // Computes the geometric mean of a set of rms measurements.
197
+ BenchmarkSuite.GeometricMeanLatency = function (measurements) {
198
+ var log = 0;
199
+ var hasLatencyResult = false;
200
+ for (var i = 0; i < measurements.length; i++) {
201
+ if (measurements[i].latency != 0) {
202
+ log += Math.log(measurements[i].latency);
203
+ hasLatencyResult = true;
204
+ }
205
+ }
206
+ if (hasLatencyResult) {
207
+ return Math.pow(Math.E, log / measurements.length);
208
+ } else {
209
+ return 0;
210
+ }
211
+ };
212
+
213
+ // Converts a score value to a string with at least three significant
214
+ // digits.
215
+ BenchmarkSuite.FormatScore = function (value) {
216
+ if (value > 100) {
217
+ return value.toFixed(0);
218
+ } else {
219
+ return value.toPrecision(3);
220
+ }
221
+ };
222
+
223
+ // Notifies the runner that we're done running a single benchmark in
224
+ // the benchmark suite. This can be useful to report progress.
225
+ BenchmarkSuite.prototype.NotifyStep = function (result) {
226
+ this.results.push(result);
227
+ if (this.runner.NotifyStep) this.runner.NotifyStep(result.benchmark.name);
228
+ };
229
+
230
+ // Notifies the runner that we're done with running a suite and that
231
+ // we have a result which can be reported to the user if needed.
232
+ BenchmarkSuite.prototype.NotifyResult = function () {
233
+ var mean = BenchmarkSuite.GeometricMeanTime(this.results);
234
+ var score = this.reference[0] / mean;
235
+ BenchmarkSuite.scores.push(score);
236
+ if (this.runner.NotifyResult) {
237
+ var formatted = BenchmarkSuite.FormatScore(100 * score);
238
+ this.runner.NotifyResult(this.name, formatted);
239
+ }
240
+ if (this.reference.length == 2) {
241
+ var meanLatency = BenchmarkSuite.GeometricMeanLatency(this.results);
242
+ if (meanLatency != 0) {
243
+ var scoreLatency = this.reference[1] / meanLatency;
244
+ BenchmarkSuite.scores.push(scoreLatency);
245
+ if (this.runner.NotifyResult) {
246
+ var formattedLatency = BenchmarkSuite.FormatScore(100 * scoreLatency);
247
+ this.runner.NotifyResult(this.name + "Latency", formattedLatency);
248
+ }
249
+ }
250
+ }
251
+ };
252
+
253
+ BenchmarkSuite.prototype.NotifySkipped = function (runner) {
254
+ BenchmarkSuite.scores.push(1); // push default reference score.
255
+ if (runner.NotifyResult) {
256
+ runner.NotifyResult(this.name, "Skipped");
257
+ }
258
+ };
259
+
260
+ // Notifies the runner that running a benchmark resulted in an error.
261
+ BenchmarkSuite.prototype.NotifyError = function (error) {
262
+ if (this.runner.NotifyError) {
263
+ this.runner.NotifyError(this.name, error);
264
+ }
265
+ if (this.runner.NotifyStep) {
266
+ this.runner.NotifyStep(this.name);
267
+ }
268
+ };
269
+
270
+ // Runs a single benchmark for at least a second and computes the
271
+ // average time it takes to run a single iteration.
272
+ BenchmarkSuite.prototype.RunSingleBenchmark = function (benchmark, data) {
273
+ var config = BenchmarkSuite.config;
274
+ var doWarmup = config.doWarmup !== undefined ? config.doWarmup : benchmark.doWarmup;
275
+ var doDeterministic = config.doDeterministic !== undefined ? config.doDeterministic : benchmark.doDeterministic;
276
+
277
+ function Measure(data) {
278
+ var elapsed = 0;
279
+ var start = new Date();
280
+
281
+ // Run either for 1 second or for the number of iterations specified
282
+ // by minIterations, depending on the config flag doDeterministic.
283
+ for (var i = 0; doDeterministic ? i < benchmark.deterministicIterations : elapsed < 1000; i++) {
284
+ benchmark.run();
285
+ elapsed = new Date() - start;
286
+ }
287
+ if (data != null) {
288
+ data.runs += i;
289
+ data.elapsed += elapsed;
290
+ }
291
+ }
292
+
293
+ // Sets up data in order to skip or not the warmup phase.
294
+ if (!doWarmup && data == null) {
295
+ data = { runs: 0, elapsed: 0 };
296
+ }
297
+
298
+ if (data == null) {
299
+ Measure(null);
300
+ return { runs: 0, elapsed: 0 };
301
+ } else {
302
+ Measure(data);
303
+ // If we've run too few iterations, we continue for another second.
304
+ if (data.runs < benchmark.minIterations) return data;
305
+ var usec = (data.elapsed * 1000) / data.runs;
306
+ var rms = benchmark.rmsResult != null ? benchmark.rmsResult() : 0;
307
+ this.NotifyStep(new BenchmarkResult(benchmark, usec, rms));
308
+ return null;
309
+ }
310
+ };
311
+
312
+ // This function starts running a suite, but stops between each
313
+ // individual benchmark in the suite and returns a continuation
314
+ // function which can be invoked to run the next benchmark. Once the
315
+ // last benchmark has been executed, null is returned.
316
+ BenchmarkSuite.prototype.RunStep = function (runner) {
317
+ BenchmarkSuite.ResetRNG();
318
+ this.results = [];
319
+ this.runner = runner;
320
+ var length = this.benchmarks.length;
321
+ var index = 0;
322
+ var suite = this;
323
+ var data;
324
+
325
+ // Run the setup, the actual benchmark, and the tear down in three
326
+ // separate steps to allow the framework to yield between any of the
327
+ // steps.
328
+
329
+ function RunNextSetup() {
330
+ if (index < length) {
331
+ try {
332
+ suite.benchmarks[index].Setup();
333
+ } catch (e) {
334
+ suite.NotifyError(e);
335
+ return null;
336
+ }
337
+ return RunNextBenchmark;
338
+ }
339
+ suite.NotifyResult();
340
+ return null;
341
+ }
342
+
343
+ function RunNextBenchmark() {
344
+ try {
345
+ data = suite.RunSingleBenchmark(suite.benchmarks[index], data);
346
+ } catch (e) {
347
+ suite.NotifyError(e);
348
+ return null;
349
+ }
350
+ // If data is null, we're done with this benchmark.
351
+ return data == null ? RunNextTearDown : RunNextBenchmark();
352
+ }
353
+
354
+ function RunNextTearDown() {
355
+ try {
356
+ suite.benchmarks[index++].TearDown();
357
+ } catch (e) {
358
+ suite.NotifyError(e);
359
+ return null;
360
+ }
361
+ return RunNextSetup;
362
+ }
363
+
364
+ // Start out running the setup.
365
+ return RunNextSetup();
366
+ };
367
+ // Copyright 2006-2008 the V8 project authors. All rights reserved.
368
+ // Redistribution and use in source and binary forms, with or without
369
+ // modification, are permitted provided that the following conditions are
370
+ // met:
371
+ //
372
+ // * Redistributions of source code must retain the above copyright
373
+ // notice, this list of conditions and the following disclaimer.
374
+ // * Redistributions in binary form must reproduce the above
375
+ // copyright notice, this list of conditions and the following
376
+ // disclaimer in the documentation and/or other materials provided
377
+ // with the distribution.
378
+ // * Neither the name of Google Inc. nor the names of its
379
+ // contributors may be used to endorse or promote products derived
380
+ // from this software without specific prior written permission.
381
+ //
382
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
383
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
384
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
385
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
386
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
387
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
388
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
389
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
390
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
391
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
392
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
393
+
394
+ // This is a JavaScript implementation of the Richards
395
+ // benchmark from:
396
+ //
397
+ // http://www.cl.cam.ac.uk/~mr10/Bench.html
398
+ //
399
+ // The benchmark was originally implemented in BCPL by
400
+ // Martin Richards.
401
+
402
+ var Richards = new BenchmarkSuite("Richards", [35302], [new Benchmark("Richards", true, false, 8200, runRichards)]);
403
+
404
+ /**
405
+ * The Richards benchmark simulates the task dispatcher of an
406
+ * operating system.
407
+ **/
408
+ function runRichards() {
409
+ var scheduler = new Scheduler();
410
+ scheduler.addIdleTask(ID_IDLE, 0, null, COUNT);
411
+
412
+ var queue = new Packet(null, ID_WORKER, KIND_WORK);
413
+ queue = new Packet(queue, ID_WORKER, KIND_WORK);
414
+ scheduler.addWorkerTask(ID_WORKER, 1000, queue);
415
+
416
+ queue = new Packet(null, ID_DEVICE_A, KIND_DEVICE);
417
+ queue = new Packet(queue, ID_DEVICE_A, KIND_DEVICE);
418
+ queue = new Packet(queue, ID_DEVICE_A, KIND_DEVICE);
419
+ scheduler.addHandlerTask(ID_HANDLER_A, 2000, queue);
420
+
421
+ queue = new Packet(null, ID_DEVICE_B, KIND_DEVICE);
422
+ queue = new Packet(queue, ID_DEVICE_B, KIND_DEVICE);
423
+ queue = new Packet(queue, ID_DEVICE_B, KIND_DEVICE);
424
+ scheduler.addHandlerTask(ID_HANDLER_B, 3000, queue);
425
+
426
+ scheduler.addDeviceTask(ID_DEVICE_A, 4000, null);
427
+
428
+ scheduler.addDeviceTask(ID_DEVICE_B, 5000, null);
429
+
430
+ scheduler.schedule();
431
+
432
+ if (scheduler.queueCount != EXPECTED_QUEUE_COUNT || scheduler.holdCount != EXPECTED_HOLD_COUNT) {
433
+ var msg =
434
+ "Error during execution: queueCount = " + scheduler.queueCount + ", holdCount = " + scheduler.holdCount + ".";
435
+ throw new Error(msg);
436
+ }
437
+ }
438
+
439
+ var COUNT = 1000;
440
+
441
+ /**
442
+ * These two constants specify how many times a packet is queued and
443
+ * how many times a task is put on hold in a correct run of richards.
444
+ * They don't have any meaning a such but are characteristic of a
445
+ * correct run so if the actual queue or hold count is different from
446
+ * the expected there must be a bug in the implementation.
447
+ **/
448
+ var EXPECTED_QUEUE_COUNT = 2322;
449
+ var EXPECTED_HOLD_COUNT = 928;
450
+
451
+ /**
452
+ * A scheduler can be used to schedule a set of tasks based on their relative
453
+ * priorities. Scheduling is done by maintaining a list of task control blocks
454
+ * which holds tasks and the data queue they are processing.
455
+ * @constructor
456
+ */
457
+ function Scheduler() {
458
+ this.queueCount = 0;
459
+ this.holdCount = 0;
460
+ this.blocks = new Array(NUMBER_OF_IDS);
461
+ this.list = null;
462
+ this.currentTcb = null;
463
+ this.currentId = null;
464
+ }
465
+
466
+ var ID_IDLE = 0;
467
+ var ID_WORKER = 1;
468
+ var ID_HANDLER_A = 2;
469
+ var ID_HANDLER_B = 3;
470
+ var ID_DEVICE_A = 4;
471
+ var ID_DEVICE_B = 5;
472
+ var NUMBER_OF_IDS = 6;
473
+
474
+ var KIND_DEVICE = 0;
475
+ var KIND_WORK = 1;
476
+
477
+ /**
478
+ * Add an idle task to this scheduler.
479
+ * @param {int} id the identity of the task
480
+ * @param {int} priority the task's priority
481
+ * @param {Packet} queue the queue of work to be processed by the task
482
+ * @param {int} count the number of times to schedule the task
483
+ */
484
+ Scheduler.prototype.addIdleTask = function (id, priority, queue, count) {
485
+ this.addRunningTask(id, priority, queue, new IdleTask(this, 1, count));
486
+ };
487
+
488
+ /**
489
+ * Add a work task to this scheduler.
490
+ * @param {int} id the identity of the task
491
+ * @param {int} priority the task's priority
492
+ * @param {Packet} queue the queue of work to be processed by the task
493
+ */
494
+ Scheduler.prototype.addWorkerTask = function (id, priority, queue) {
495
+ this.addTask(id, priority, queue, new WorkerTask(this, ID_HANDLER_A, 0));
496
+ };
497
+
498
+ /**
499
+ * Add a handler task to this scheduler.
500
+ * @param {int} id the identity of the task
501
+ * @param {int} priority the task's priority
502
+ * @param {Packet} queue the queue of work to be processed by the task
503
+ */
504
+ Scheduler.prototype.addHandlerTask = function (id, priority, queue) {
505
+ this.addTask(id, priority, queue, new HandlerTask(this));
506
+ };
507
+
508
+ /**
509
+ * Add a handler task to this scheduler.
510
+ * @param {int} id the identity of the task
511
+ * @param {int} priority the task's priority
512
+ * @param {Packet} queue the queue of work to be processed by the task
513
+ */
514
+ Scheduler.prototype.addDeviceTask = function (id, priority, queue) {
515
+ this.addTask(id, priority, queue, new DeviceTask(this));
516
+ };
517
+
518
+ /**
519
+ * Add the specified task and mark it as running.
520
+ * @param {int} id the identity of the task
521
+ * @param {int} priority the task's priority
522
+ * @param {Packet} queue the queue of work to be processed by the task
523
+ * @param {Task} task the task to add
524
+ */
525
+ Scheduler.prototype.addRunningTask = function (id, priority, queue, task) {
526
+ this.addTask(id, priority, queue, task);
527
+ this.currentTcb.setRunning();
528
+ };
529
+
530
+ /**
531
+ * Add the specified task to this scheduler.
532
+ * @param {int} id the identity of the task
533
+ * @param {int} priority the task's priority
534
+ * @param {Packet} queue the queue of work to be processed by the task
535
+ * @param {Task} task the task to add
536
+ */
537
+ Scheduler.prototype.addTask = function (id, priority, queue, task) {
538
+ this.currentTcb = new TaskControlBlock(this.list, id, priority, queue, task);
539
+ this.list = this.currentTcb;
540
+ this.blocks[id] = this.currentTcb;
541
+ };
542
+
543
+ /**
544
+ * Execute the tasks managed by this scheduler.
545
+ */
546
+ Scheduler.prototype.schedule = function () {
547
+ this.currentTcb = this.list;
548
+ while (this.currentTcb != null) {
549
+ if (this.currentTcb.isHeldOrSuspended()) {
550
+ this.currentTcb = this.currentTcb.link;
551
+ } else {
552
+ this.currentId = this.currentTcb.id;
553
+ this.currentTcb = this.currentTcb.run();
554
+ }
555
+ }
556
+ };
557
+
558
+ /**
559
+ * Release a task that is currently blocked and return the next block to run.
560
+ * @param {int} id the id of the task to suspend
561
+ */
562
+ Scheduler.prototype.release = function (id) {
563
+ var tcb = this.blocks[id];
564
+ if (tcb == null) return tcb;
565
+ tcb.markAsNotHeld();
566
+ if (tcb.priority > this.currentTcb.priority) {
567
+ return tcb;
568
+ } else {
569
+ return this.currentTcb;
570
+ }
571
+ };
572
+
573
+ /**
574
+ * Block the currently executing task and return the next task control block
575
+ * to run. The blocked task will not be made runnable until it is explicitly
576
+ * released, even if new work is added to it.
577
+ */
578
+ Scheduler.prototype.holdCurrent = function () {
579
+ this.holdCount++;
580
+ this.currentTcb.markAsHeld();
581
+ return this.currentTcb.link;
582
+ };
583
+
584
+ /**
585
+ * Suspend the currently executing task and return the next task control block
586
+ * to run. If new work is added to the suspended task it will be made runnable.
587
+ */
588
+ Scheduler.prototype.suspendCurrent = function () {
589
+ this.currentTcb.markAsSuspended();
590
+ return this.currentTcb;
591
+ };
592
+
593
+ /**
594
+ * Add the specified packet to the end of the worklist used by the task
595
+ * associated with the packet and make the task runnable if it is currently
596
+ * suspended.
597
+ * @param {Packet} packet the packet to add
598
+ */
599
+ Scheduler.prototype.queue = function (packet) {
600
+ var t = this.blocks[packet.id];
601
+ if (t == null) return t;
602
+ this.queueCount++;
603
+ packet.link = null;
604
+ packet.id = this.currentId;
605
+ return t.checkPriorityAdd(this.currentTcb, packet);
606
+ };
607
+
608
+ /**
609
+ * A task control block manages a task and the queue of work packages associated
610
+ * with it.
611
+ * @param {TaskControlBlock} link the preceding block in the linked block list
612
+ * @param {int} id the id of this block
613
+ * @param {int} priority the priority of this block
614
+ * @param {Packet} queue the queue of packages to be processed by the task
615
+ * @param {Task} task the task
616
+ * @constructor
617
+ */
618
+ function TaskControlBlock(link, id, priority, queue, task) {
619
+ this.link = link;
620
+ this.id = id;
621
+ this.priority = priority;
622
+ this.queue = queue;
623
+ this.task = task;
624
+ if (queue == null) {
625
+ this.state = STATE_SUSPENDED;
626
+ } else {
627
+ this.state = STATE_SUSPENDED_RUNNABLE;
628
+ }
629
+ }
630
+
631
+ /**
632
+ * The task is running and is currently scheduled.
633
+ */
634
+ var STATE_RUNNING = 0;
635
+
636
+ /**
637
+ * The task has packets left to process.
638
+ */
639
+ var STATE_RUNNABLE = 1;
640
+
641
+ /**
642
+ * The task is not currently running. The task is not blocked as such and may
643
+ * be started by the scheduler.
644
+ */
645
+ var STATE_SUSPENDED = 2;
646
+
647
+ /**
648
+ * The task is blocked and cannot be run until it is explicitly released.
649
+ */
650
+ var STATE_HELD = 4;
651
+
652
+ var STATE_SUSPENDED_RUNNABLE = STATE_SUSPENDED | STATE_RUNNABLE;
653
+ var STATE_NOT_HELD = ~STATE_HELD;
654
+
655
+ TaskControlBlock.prototype.setRunning = function () {
656
+ this.state = STATE_RUNNING;
657
+ };
658
+
659
+ TaskControlBlock.prototype.markAsNotHeld = function () {
660
+ this.state = this.state & STATE_NOT_HELD;
661
+ };
662
+
663
+ TaskControlBlock.prototype.markAsHeld = function () {
664
+ this.state = this.state | STATE_HELD;
665
+ };
666
+
667
+ TaskControlBlock.prototype.isHeldOrSuspended = function () {
668
+ return (this.state & STATE_HELD) != 0 || this.state == STATE_SUSPENDED;
669
+ };
670
+
671
+ TaskControlBlock.prototype.markAsSuspended = function () {
672
+ this.state = this.state | STATE_SUSPENDED;
673
+ };
674
+
675
+ TaskControlBlock.prototype.markAsRunnable = function () {
676
+ this.state = this.state | STATE_RUNNABLE;
677
+ };
678
+
679
+ /**
680
+ * Runs this task, if it is ready to be run, and returns the next task to run.
681
+ */
682
+ TaskControlBlock.prototype.run = function () {
683
+ var packet;
684
+ if (this.state == STATE_SUSPENDED_RUNNABLE) {
685
+ packet = this.queue;
686
+ this.queue = packet.link;
687
+ if (this.queue == null) {
688
+ this.state = STATE_RUNNING;
689
+ } else {
690
+ this.state = STATE_RUNNABLE;
691
+ }
692
+ } else {
693
+ packet = null;
694
+ }
695
+ return this.task.run(packet);
696
+ };
697
+
698
+ /**
699
+ * Adds a packet to the worklist of this block's task, marks this as runnable if
700
+ * necessary, and returns the next runnable object to run (the one
701
+ * with the highest priority).
702
+ */
703
+ TaskControlBlock.prototype.checkPriorityAdd = function (task, packet) {
704
+ if (this.queue == null) {
705
+ this.queue = packet;
706
+ this.markAsRunnable();
707
+ if (this.priority > task.priority) return this;
708
+ } else {
709
+ this.queue = packet.addTo(this.queue);
710
+ }
711
+ return task;
712
+ };
713
+
714
+ TaskControlBlock.prototype.toString = function () {
715
+ return "tcb { " + this.task + "@" + this.state + " }";
716
+ };
717
+
718
+ /**
719
+ * An idle task doesn't do any work itself but cycles control between the two
720
+ * device tasks.
721
+ * @param {Scheduler} scheduler the scheduler that manages this task
722
+ * @param {int} v1 a seed value that controls how the device tasks are scheduled
723
+ * @param {int} count the number of times this task should be scheduled
724
+ * @constructor
725
+ */
726
+ function IdleTask(scheduler, v1, count) {
727
+ this.scheduler = scheduler;
728
+ this.v1 = v1;
729
+ this.count = count;
730
+ }
731
+
732
+ IdleTask.prototype.run = function (packet) {
733
+ this.count--;
734
+ if (this.count == 0) return this.scheduler.holdCurrent();
735
+ if ((this.v1 & 1) == 0) {
736
+ this.v1 = this.v1 >> 1;
737
+ return this.scheduler.release(ID_DEVICE_A);
738
+ } else {
739
+ this.v1 = (this.v1 >> 1) ^ 0xd008;
740
+ return this.scheduler.release(ID_DEVICE_B);
741
+ }
742
+ };
743
+
744
+ IdleTask.prototype.toString = function () {
745
+ return "IdleTask";
746
+ };
747
+
748
+ /**
749
+ * A task that suspends itself after each time it has been run to simulate
750
+ * waiting for data from an external device.
751
+ * @param {Scheduler} scheduler the scheduler that manages this task
752
+ * @constructor
753
+ */
754
+ function DeviceTask(scheduler) {
755
+ this.scheduler = scheduler;
756
+ this.v1 = null;
757
+ }
758
+
759
+ DeviceTask.prototype.run = function (packet) {
760
+ if (packet == null) {
761
+ if (this.v1 == null) return this.scheduler.suspendCurrent();
762
+ var v = this.v1;
763
+ this.v1 = null;
764
+ return this.scheduler.queue(v);
765
+ } else {
766
+ this.v1 = packet;
767
+ return this.scheduler.holdCurrent();
768
+ }
769
+ };
770
+
771
+ DeviceTask.prototype.toString = function () {
772
+ return "DeviceTask";
773
+ };
774
+
775
+ /**
776
+ * A task that manipulates work packets.
777
+ * @param {Scheduler} scheduler the scheduler that manages this task
778
+ * @param {int} v1 a seed used to specify how work packets are manipulated
779
+ * @param {int} v2 another seed used to specify how work packets are manipulated
780
+ * @constructor
781
+ */
782
+ function WorkerTask(scheduler, v1, v2) {
783
+ this.scheduler = scheduler;
784
+ this.v1 = v1;
785
+ this.v2 = v2;
786
+ }
787
+
788
+ WorkerTask.prototype.run = function (packet) {
789
+ if (packet == null) {
790
+ return this.scheduler.suspendCurrent();
791
+ } else {
792
+ if (this.v1 == ID_HANDLER_A) {
793
+ this.v1 = ID_HANDLER_B;
794
+ } else {
795
+ this.v1 = ID_HANDLER_A;
796
+ }
797
+ packet.id = this.v1;
798
+ packet.a1 = 0;
799
+ for (var i = 0; i < DATA_SIZE; i++) {
800
+ this.v2++;
801
+ if (this.v2 > 26) this.v2 = 1;
802
+ packet.a2[i] = this.v2;
803
+ }
804
+ return this.scheduler.queue(packet);
805
+ }
806
+ };
807
+
808
+ WorkerTask.prototype.toString = function () {
809
+ return "WorkerTask";
810
+ };
811
+
812
+ /**
813
+ * A task that manipulates work packets and then suspends itself.
814
+ * @param {Scheduler} scheduler the scheduler that manages this task
815
+ * @constructor
816
+ */
817
+ function HandlerTask(scheduler) {
818
+ this.scheduler = scheduler;
819
+ this.v1 = null;
820
+ this.v2 = null;
821
+ }
822
+
823
+ HandlerTask.prototype.run = function (packet) {
824
+ if (packet != null) {
825
+ if (packet.kind == KIND_WORK) {
826
+ this.v1 = packet.addTo(this.v1);
827
+ } else {
828
+ this.v2 = packet.addTo(this.v2);
829
+ }
830
+ }
831
+ if (this.v1 != null) {
832
+ var count = this.v1.a1;
833
+ var v;
834
+ if (count < DATA_SIZE) {
835
+ if (this.v2 != null) {
836
+ v = this.v2;
837
+ this.v2 = this.v2.link;
838
+ v.a1 = this.v1.a2[count];
839
+ this.v1.a1 = count + 1;
840
+ return this.scheduler.queue(v);
841
+ }
842
+ } else {
843
+ v = this.v1;
844
+ this.v1 = this.v1.link;
845
+ return this.scheduler.queue(v);
846
+ }
847
+ }
848
+ return this.scheduler.suspendCurrent();
849
+ };
850
+
851
+ HandlerTask.prototype.toString = function () {
852
+ return "HandlerTask";
853
+ };
854
+
855
+ /* --- *
856
+ * P a c k e t
857
+ * --- */
858
+
859
+ var DATA_SIZE = 4;
860
+
861
+ /**
862
+ * A simple package of data that is manipulated by the tasks. The exact layout
863
+ * of the payload data carried by a packet is not importaint, and neither is the
864
+ * nature of the work performed on packets by the tasks.
865
+ *
866
+ * Besides carrying data, packets form linked lists and are hence used both as
867
+ * data and worklists.
868
+ * @param {Packet} link the tail of the linked list of packets
869
+ * @param {int} id an ID for this packet
870
+ * @param {int} kind the type of this packet
871
+ * @constructor
872
+ */
873
+ function Packet(link, id, kind) {
874
+ this.link = link;
875
+ this.id = id;
876
+ this.kind = kind;
877
+ this.a1 = 0;
878
+ this.a2 = new Array(DATA_SIZE);
879
+ }
880
+
881
+ /**
882
+ * Add this packet to the end of a worklist, and return the worklist.
883
+ * @param {Packet} queue the worklist to add this packet to
884
+ */
885
+ Packet.prototype.addTo = function (queue) {
886
+ this.link = null;
887
+ if (queue == null) return this;
888
+ var peek,
889
+ next = queue;
890
+ while ((peek = next.link) != null) next = peek;
891
+ next.link = this;
892
+ return queue;
893
+ };
894
+
895
+ Packet.prototype.toString = function () {
896
+ return "Packet";
897
+ };
898
+ // Copyright 2014 the V8 project authors. All rights reserved.
899
+ // Redistribution and use in source and binary forms, with or without
900
+ // modification, are permitted provided that the following conditions are
901
+ // met:
902
+ //
903
+ // * Redistributions of source code must retain the above copyright
904
+ // notice, this list of conditions and the following disclaimer.
905
+ // * Redistributions in binary form must reproduce the above
906
+ // copyright notice, this list of conditions and the following
907
+ // disclaimer in the documentation and/or other materials provided
908
+ // with the distribution.
909
+ // * Neither the name of Google Inc. nor the names of its
910
+ // contributors may be used to endorse or promote products derived
911
+ // from this software without specific prior written permission.
912
+ //
913
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
914
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
915
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
916
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
917
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
918
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
919
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
920
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
921
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
922
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
923
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
924
+
925
+ var base_dir = "";
926
+ var success = true;
927
+
928
+ function PrintResult(name, result) {
929
+ console.log(name + ": " + result);
930
+ }
931
+
932
+ function PrintError(name, error) {
933
+ PrintResult(name, error);
934
+ success = false;
935
+ }
936
+
937
+ function PrintScore(score) {
938
+ if (success) {
939
+ console.log("----");
940
+ console.log("Score (version " + BenchmarkSuite.version + "): " + score);
941
+ }
942
+ }
943
+
944
+ BenchmarkSuite.config.doWarmup = undefined;
945
+ BenchmarkSuite.config.doDeterministic = undefined;
946
+
947
+ function main() {
948
+ BenchmarkSuite.RunSuites({ NotifyResult: PrintResult, NotifyError: PrintError, NotifyScore: PrintScore });
949
+ }
950
+
951
+ main();
package/runner/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.49.1';
3
+ globalThis.version = '0.49.3';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {