diff --git a/JetStreamDriver.js b/JetStreamDriver.js index c0c3d71..7e0eb62 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -52,14 +52,22 @@ function getIntParam(urlParams, key) { return value } +function getTestListParam(urlParams, key) { + if (globalThis.customTestList.length) + throw new Error(`Overriding previous customTestList=${globalThis.customTestList.join()} with ${key} url-parameter.`); + return urlParams.getAll(key); +} + if (typeof(URLSearchParams) !== "undefined") { const urlParameters = new URLSearchParams(window.location.search); shouldReport = urlParameters.has('report') && urlParameters.get('report').toLowerCase() == 'true'; globalThis.startDelay = getIntParam(urlParameters, "startDelay"); if (shouldReport && !globalThis.startDelay) globalThis.startDelay = 4000; - if (urlParameters.has('test')) - customTestList = urlParameters.getAll("test"); + if (urlParameters.has("tag")) + customTestList = getTestListParam(urlParameters, "tag"); + if (urlParameters.has("test")) + customTestList = getTestListParam(urlParameters, "test"); globalThis.testIterationCount = getIntParam(urlParameters, "iterationCount"); globalThis.testWorstCaseCount = getIntParam(urlParameters, "worstCaseCount"); } @@ -212,7 +220,7 @@ class Driver { this.isReady = false; this.isDone = false; this.errors = []; - this.benchmarks = []; + this.benchmarks = new Set(); // TODO: Cleanup / remove / merge `blobDataCache` and `loadCache` vs. // the global `fileLoader` cache. this.blobDataCache = { }; @@ -223,10 +231,34 @@ class Driver { this.counter.failedPreloadResources = 0; } - // TODO: Remove, make `this.benchmarks` immutable and set it once in the - // ctor instead of this and the global `addBenchmarksBy*` functions. - addBenchmark(benchmark) { - this.benchmarks.push(benchmark); + enableBenchmark(benchmark) { + // TODO: Remove, make `this.benchmarks` immutable and set it once in the + // ctor instead of this and the global `addBenchmarksBy*` functions. + this.benchmarks.add(benchmark); + } + + enableBenchmarksByName(name) { + const benchmark = benchmarksByName.get(name.toLowerCase()); + + if (!benchmark) + throw new Error(`Couldn't find benchmark named "${name}"`); + + this.enableBenchmark(benchmark); + } + + enableBenchmarksByTag(tag, excludeTags) { + const benchmarks = benchmarksByTag.get(tag.toLowerCase()); + + if (!benchmarks) { + const validTags = Array.from(benchmarksByTag.keys()).join(", "); + throw new Error(`Couldn't find tag named: ${tag}.\n Choices are ${validTags}`); + } + + for (const benchmark of benchmarks) { + if (excludeTags && benchmark.hasAnyTag(...excludeTags)) + continue + this.enableBenchmark(benchmark); + } } async start() { @@ -373,12 +405,10 @@ class Driver { this.benchmarks.sort((a, b) => a.plan.name.toLowerCase() < b.plan.name.toLowerCase() ? 1 : -1); let text = ""; - let newBenchmarks = []; for (const benchmark of this.benchmarks) { const description = Object.keys(benchmark.subScores()); description.push("Score"); - newBenchmarks.push(benchmark); const scoreIds = benchmark.scoreIdentifiers(); const overallScoreId = scoreIds.pop(); @@ -436,9 +466,15 @@ class Driver { }); } + initializeBenchmarks() { + this.benchmarks = Array.from(this.benchmarks); + this.benchmarks.sort((a, b) => a.plan.name.toLowerCase() < b.plan.name.toLowerCase() ? 1 : -1); + } + async initialize() { if (isInBrowser) window.addEventListener("error", (e) => this.pushError("driver startup", e.error)); + this.initializeBenchmarks(); await this.prefetchResources(); this.prepareToRun(); this.isReady = true; @@ -591,10 +627,11 @@ class Benchmark { constructor(plan) { this.plan = plan; - this.tags = new Set(plan.tags); + this.tags = new Set(plan.tags.map(each => each.toLowerCase())); + if (this.tags.size != plan.tags.length) + throw new Error(`${this.name} got duplicate tags: ${plan.tags.join()}`); this.iterations = getIterationCount(plan); this.isAsync = !!plan.isAsync; - this.disabledByDefault = !!plan.disabledByDefault; this.scripts = null; this.preloads = null; this._state = BenchmarkState.READY; @@ -607,6 +644,10 @@ class Benchmark { } get isSuccess() { return this._state = BenchmarkState.DONE; } + hasAnyTag(...tags) { + return tags.some((tag) => this.tags.has(tag.toLowerCase())); + } + get runnerCode() { return ` let __benchmark = new Benchmark(${this.iterations}); @@ -1515,7 +1556,7 @@ let BENCHMARKS = [ , "./ARES-6/Air/payload-typescript-scanIdentifier.js" , "./ARES-6/Air/benchmark.js" ], - tags: ["ARES"], + tags: ["Default", "ARES"], }), new DefaultBenchmark({ name: "Basic", @@ -1531,7 +1572,7 @@ let BENCHMARKS = [ , "./ARES-6/Basic/util.js" , "./ARES-6/Basic/benchmark.js" ], - tags: ["ARES"], + tags: ["Default", "ARES"], }), new DefaultBenchmark({ name: "ML", @@ -1540,7 +1581,7 @@ let BENCHMARKS = [ , "./ARES-6/ml/benchmark.js" ], iterations: 60, - tags: ["ARES"], + tags: ["Default", "ARES"], }), new AsyncBenchmark({ name: "Babylon", @@ -1554,7 +1595,7 @@ let BENCHMARKS = [ inspectorBlob: "./ARES-6/Babylon/inspector-blob.js", babylonBlob: "./ARES-6/Babylon/babylon-blob.js" }, - tags: ["ARES"], + tags: ["Default", "ARES"], }), // CDJS new DefaultBenchmark({ @@ -1575,7 +1616,7 @@ let BENCHMARKS = [ ], iterations: 60, worstCaseCount: 3, - tags: ["CDJS"], + tags: ["Default", "CDJS"], }), // CodeLoad new AsyncBenchmark({ @@ -1586,7 +1627,7 @@ let BENCHMARKS = [ preload: { inspectorPayloadBlob: "./code-load/inspector-payload-minified.js" }, - tags: ["CodeLoad"], + tags: ["Default", "CodeLoad"], }), new AsyncBenchmark({ name: "multi-inspector-code-load", @@ -1596,7 +1637,7 @@ let BENCHMARKS = [ preload: { inspectorPayloadBlob: "./code-load/inspector-payload-minified.js" }, - tags: ["CodeLoad"], + tags: ["Default", "CodeLoad"], }), // Octane new DefaultBenchmark({ @@ -1605,7 +1646,7 @@ let BENCHMARKS = [ "./Octane/box2d.js" ], deterministicRandom: true, - tags: ["Octane"], + tags: ["Default", "Octane"], }), new DefaultBenchmark({ name: "octane-code-load", @@ -1613,7 +1654,7 @@ let BENCHMARKS = [ "./Octane/code-first-load.js" ], deterministicRandom: true, - tags: ["Octane"], + tags: ["Default", "Octane"], }), new DefaultBenchmark({ name: "crypto", @@ -1621,7 +1662,7 @@ let BENCHMARKS = [ "./Octane/crypto.js" ], deterministicRandom: true, - tags: ["Octane"], + tags: ["Default", "Octane"], }), new DefaultBenchmark({ name: "delta-blue", @@ -1629,7 +1670,7 @@ let BENCHMARKS = [ "./Octane/deltablue.js" ], deterministicRandom: true, - tags: ["Octane"], + tags: ["Default", "Octane"], }), new DefaultBenchmark({ name: "earley-boyer", @@ -1637,7 +1678,7 @@ let BENCHMARKS = [ "./Octane/earley-boyer.js" ], deterministicRandom: true, - tags: ["Octane"], + tags: ["Default", "Octane"], }), new DefaultBenchmark({ name: "gbemu", @@ -1646,7 +1687,7 @@ let BENCHMARKS = [ , "./Octane/gbemu-part2.js" ], deterministicRandom: true, - tags: ["Octane"], + tags: ["Default", "Octane"], }), new DefaultBenchmark({ name: "mandreel", @@ -1655,7 +1696,7 @@ let BENCHMARKS = [ ], iterations: 80, deterministicRandom: true, - tags: ["Octane"], + tags: ["Default", "Octane"], }), new DefaultBenchmark({ name: "navier-stokes", @@ -1663,7 +1704,7 @@ let BENCHMARKS = [ "./Octane/navier-stokes.js" ], deterministicRandom: true, - tags: ["Octane"], + tags: ["Default", "Octane"], }), new DefaultBenchmark({ name: "pdfjs", @@ -1671,14 +1712,14 @@ let BENCHMARKS = [ "./Octane/pdfjs.js" ], deterministicRandom: true, - tags: ["Octane"], + tags: ["Default", "Octane"], }), new DefaultBenchmark({ name: "raytrace", files: [ "./Octane/raytrace.js" ], - tags: ["Octane"], + tags: ["Default", "Octane"], }), new DefaultBenchmark({ name: "regexp", @@ -1686,7 +1727,7 @@ let BENCHMARKS = [ "./Octane/regexp.js" ], deterministicRandom: true, - tags: ["Octane"], + tags: ["Default", "Octane"], }), new DefaultBenchmark({ name: "richards", @@ -1694,7 +1735,7 @@ let BENCHMARKS = [ "./Octane/richards.js" ], deterministicRandom: true, - tags: ["Octane"], + tags: ["Default", "Octane"], }), new DefaultBenchmark({ name: "splay", @@ -1702,7 +1743,7 @@ let BENCHMARKS = [ "./Octane/splay.js" ], deterministicRandom: true, - tags: ["Octane"], + tags: ["Default", "Octane"], }), new DefaultBenchmark({ name: "typescript", @@ -1714,7 +1755,7 @@ let BENCHMARKS = [ iterations: 15, worstCaseCount: 2, deterministicRandom: true, - tags: ["Octane"], + tags: ["Default", "Octane"], }), // RexBench new DefaultBenchmark({ @@ -1726,7 +1767,7 @@ let BENCHMARKS = [ , "./RexBench/FlightPlanner/expectations.js" , "./RexBench/FlightPlanner/benchmark.js" ], - tags: ["RexBench"], + tags: ["Default", "RexBench"], }), new DefaultBenchmark({ name: "OfflineAssembler", @@ -1744,7 +1785,7 @@ let BENCHMARKS = [ , "./RexBench/OfflineAssembler/benchmark.js" ], iterations: 80, - tags: ["RexBench"], + tags: ["Default", "RexBench"], }), new DefaultBenchmark({ name: "UniPoker", @@ -1754,7 +1795,7 @@ let BENCHMARKS = [ , "./RexBench/UniPoker/benchmark.js" ], deterministicRandom: true, - tags: ["RexBench"], + tags: ["Default", "RexBench"], }), // Simple new DefaultBenchmark({ @@ -1762,21 +1803,21 @@ let BENCHMARKS = [ files: [ "./simple/hash-map.js" ], - tags: ["Simple"], + tags: ["Default", "Simple"], }), new AsyncBenchmark({ name: "doxbee-promise", files: [ "./simple/doxbee-promise.js", ], - tags: ["Simple"], + tags: ["Default", "Simple"], }), new AsyncBenchmark({ name: "doxbee-async", files: [ "./simple/doxbee-async.js", ], - tags: ["Simple"], + tags: ["Default", "Simple"], }), // SeaMonster new DefaultBenchmark({ @@ -1784,14 +1825,14 @@ let BENCHMARKS = [ files: [ "./SeaMonster/ai-astar.js" ], - tags: ["SeaMonster"], + tags: ["Default", "SeaMonster"], }), new DefaultBenchmark({ name: "gaussian-blur", files: [ "./SeaMonster/gaussian-blur.js" ], - tags: ["SeaMonster"], + tags: ["Default", "SeaMonster"], }), new DefaultBenchmark({ name: "stanford-crypto-aes", @@ -1799,7 +1840,7 @@ let BENCHMARKS = [ "./SeaMonster/sjlc.js" , "./SeaMonster/stanford-crypto-aes.js" ], - tags: ["SeaMonster"], + tags: ["Default", "SeaMonster"], }), new DefaultBenchmark({ name: "stanford-crypto-pbkdf2", @@ -1807,7 +1848,7 @@ let BENCHMARKS = [ "./SeaMonster/sjlc.js" , "./SeaMonster/stanford-crypto-pbkdf2.js" ], - tags: ["SeaMonster"], + tags: ["Default", "SeaMonster"], }), new DefaultBenchmark({ name: "stanford-crypto-sha256", @@ -1815,7 +1856,7 @@ let BENCHMARKS = [ "./SeaMonster/sjlc.js" , "./SeaMonster/stanford-crypto-sha256.js" ], - tags: ["SeaMonster"], + tags: ["Default", "SeaMonster"], }), new DefaultBenchmark({ name: "json-stringify-inspector", @@ -1825,7 +1866,7 @@ let BENCHMARKS = [ ], iterations: 20, worstCaseCount: 2, - tags: ["SeaMonster"], + tags: ["Default", "SeaMonster"], }), new DefaultBenchmark({ name: "json-parse-inspector", @@ -1835,7 +1876,7 @@ let BENCHMARKS = [ ], iterations: 20, worstCaseCount: 2, - tags: ["SeaMonster"], + tags: ["Default", "SeaMonster"], }), // BigInt new AsyncBenchmark({ @@ -1849,7 +1890,6 @@ let BENCHMARKS = [ worstCaseCount: 1, deterministicRandom: true, tags: ["BigIntNoble"], - disabledByDefault: true, }), new AsyncBenchmark({ name: "bigint-noble-secp256k1", @@ -1860,7 +1900,6 @@ let BENCHMARKS = [ ], deterministicRandom: true, tags: ["BigIntNoble"], - disabledByDefault: true, }), new AsyncBenchmark({ name: "bigint-noble-ed25519", @@ -1871,7 +1910,7 @@ let BENCHMARKS = [ ], iterations: 30, deterministicRandom: true, - tags: ["BigIntNoble"], + tags: ["Default", "BigIntNoble"], }), new DefaultBenchmark({ name: "bigint-paillier", @@ -1884,7 +1923,6 @@ let BENCHMARKS = [ worstCaseCount: 2, deterministicRandom: true, tags: ["BigIntMisc"], - disabledByDefault: true, }), new DefaultBenchmark({ name: "bigint-bigdenary", @@ -1895,7 +1933,6 @@ let BENCHMARKS = [ iterations: 160, worstCaseCount: 16, tags: ["BigIntMisc"], - disabledByDefault: true, }), // Proxy new AsyncBenchmark({ @@ -1907,7 +1944,7 @@ let BENCHMARKS = [ ], iterations: defaultIterationCount * 3, worstCaseCount: defaultWorstCaseCount * 3, - tags: ["Proxy"], + tags: ["Default", "Proxy"], }), new AsyncBenchmark({ name: "proxy-vue", @@ -1916,7 +1953,7 @@ let BENCHMARKS = [ "./proxy/vue-bundle.js", "./proxy/vue-benchmark.js", ], - tags: ["Proxy"] + tags: ["Default", "Proxy"] }), // Class fields new DefaultBenchmark({ @@ -1924,14 +1961,14 @@ let BENCHMARKS = [ files: [ "./class-fields/raytrace-public-class-fields.js", ], - tags: ["ClassFields"] + tags: ["Default", "ClassFields"] }), new DefaultBenchmark({ name: "raytrace-private-class-fields", files: [ "./class-fields/raytrace-private-class-fields.js", ], - tags: ["ClassFields"] + tags: ["Default", "ClassFields"] }), // Generators new AsyncBenchmark({ @@ -1942,7 +1979,7 @@ let BENCHMARKS = [ iterations: 80, worstCaseCount: 6, deterministicRandom: true, - tags: ["Generators"] + tags: ["Default", "Generators"] }), new DefaultBenchmark({ name: "sync-fs", @@ -1952,21 +1989,21 @@ let BENCHMARKS = [ iterations: 80, worstCaseCount: 6, deterministicRandom: true, - tags: ["Generators"] + tags: ["Default", "Generators"] }), new DefaultBenchmark({ name: "lazy-collections", files: [ "./generators/lazy-collections.js", ], - tags: ["Generators"] + tags: ["Default", "Generators"] }), new DefaultBenchmark({ name: "js-tokens", files: [ "./generators/js-tokens.js", ], - tags: ["Generators"] + tags: ["Default", "Generators"] }), // Wasm new WasmEMCCBenchmark({ @@ -1979,7 +2016,7 @@ let BENCHMARKS = [ wasmBinary: "./wasm/HashSet/build/HashSet.wasm" }, iterations: 50, - tags: ["Wasm"], + tags: ["Default", "Wasm"], }), new WasmEMCCBenchmark({ name: "tsf-wasm", @@ -1991,7 +2028,7 @@ let BENCHMARKS = [ wasmBinary: "./wasm/TSF/build/tsf.wasm" }, iterations: 50, - tags: ["Wasm"], + tags: ["Default", "Wasm"], }), new WasmEMCCBenchmark({ name: "quicksort-wasm", @@ -2003,7 +2040,7 @@ let BENCHMARKS = [ wasmBinary: "./wasm/quicksort/build/quicksort.wasm" }, iterations: 50, - tags: ["Wasm"], + tags: ["Default", "Wasm"], }), new WasmEMCCBenchmark({ name: "gcc-loops-wasm", @@ -2015,7 +2052,7 @@ let BENCHMARKS = [ wasmBinary: "./wasm/gcc-loops/build/gcc-loops.wasm" }, iterations: 50, - tags: ["Wasm"], + tags: ["Default", "Wasm"], }), new WasmEMCCBenchmark({ name: "richards-wasm", @@ -2027,7 +2064,7 @@ let BENCHMARKS = [ wasmBinary: "./wasm/richards/build/richards.wasm" }, iterations: 50, - tags: ["Wasm"], + tags: ["Default", "Wasm"], }), new WasmEMCCBenchmark({ name: "sqlite3-wasm", @@ -2040,7 +2077,7 @@ let BENCHMARKS = [ }, iterations: 30, worstCaseCount: 2, - tags: ["Wasm"], + tags: ["Default", "Wasm"], }), new WasmEMCCBenchmark({ name: "Dart-flute-wasm", @@ -2053,7 +2090,7 @@ let BENCHMARKS = [ }, iterations: 15, worstCaseCount: 2, - tags: ["Wasm"], + tags: ["Default", "Wasm"], }), new WasmLegacyBenchmark({ name: "tfjs-wasm", @@ -2073,7 +2110,7 @@ let BENCHMARKS = [ }, async: true, deterministicRandom: true, - tags: ["Wasm"], + tags: ["Default", "Wasm"], }), new WasmLegacyBenchmark({ name: "tfjs-wasm-simd", @@ -2093,7 +2130,7 @@ let BENCHMARKS = [ }, async: true, deterministicRandom: true, - tags: ["Wasm"], + tags: ["Default", "Wasm"], }), new WasmEMCCBenchmark({ name: "argon2-wasm", @@ -2107,7 +2144,7 @@ let BENCHMARKS = [ iterations: 30, worstCaseCount: 3, deterministicRandom: true, - tags: ["Wasm"], + tags: ["Default", "Wasm"], }), // WorkerTests new AsyncBenchmark({ @@ -2144,7 +2181,7 @@ let BENCHMARKS = [ , stringUnpackCode: "./worker/bomb-subtests/string-unpack-code.js" , regexpDNA: "./worker/bomb-subtests/regexp-dna.js" }, - tags: ["WorkerTests"], + tags: ["Default", "WorkerTests"], }), new AsyncBenchmark({ name: "segmentation", @@ -2156,13 +2193,13 @@ let BENCHMARKS = [ }, iterations: 36, worstCaseCount: 3, - tags: ["WorkerTests"], + tags: ["Default", "WorkerTests"], }), // WSL new WSLBenchmark({ name: "WSL", files: ["./WSL/Node.js" ,"./WSL/Type.js" ,"./WSL/ReferenceType.js" ,"./WSL/Value.js" ,"./WSL/Expression.js" ,"./WSL/Rewriter.js" ,"./WSL/Visitor.js" ,"./WSL/CreateLiteral.js" ,"./WSL/CreateLiteralType.js" ,"./WSL/PropertyAccessExpression.js" ,"./WSL/AddressSpace.js" ,"./WSL/AnonymousVariable.js" ,"./WSL/ArrayRefType.js" ,"./WSL/ArrayType.js" ,"./WSL/Assignment.js" ,"./WSL/AutoWrapper.js" ,"./WSL/Block.js" ,"./WSL/BoolLiteral.js" ,"./WSL/Break.js" ,"./WSL/CallExpression.js" ,"./WSL/CallFunction.js" ,"./WSL/Check.js" ,"./WSL/CheckLiteralTypes.js" ,"./WSL/CheckLoops.js" ,"./WSL/CheckRecursiveTypes.js" ,"./WSL/CheckRecursion.js" ,"./WSL/CheckReturns.js" ,"./WSL/CheckUnreachableCode.js" ,"./WSL/CheckWrapped.js" ,"./WSL/Checker.js" ,"./WSL/CloneProgram.js" ,"./WSL/CommaExpression.js" ,"./WSL/ConstexprFolder.js" ,"./WSL/ConstexprTypeParameter.js" ,"./WSL/Continue.js" ,"./WSL/ConvertPtrToArrayRefExpression.js" ,"./WSL/DereferenceExpression.js" ,"./WSL/DoWhileLoop.js" ,"./WSL/DotExpression.js" ,"./WSL/DoubleLiteral.js" ,"./WSL/DoubleLiteralType.js" ,"./WSL/EArrayRef.js" ,"./WSL/EBuffer.js" ,"./WSL/EBufferBuilder.js" ,"./WSL/EPtr.js" ,"./WSL/EnumLiteral.js" ,"./WSL/EnumMember.js" ,"./WSL/EnumType.js" ,"./WSL/EvaluationCommon.js" ,"./WSL/Evaluator.js" ,"./WSL/ExpressionFinder.js" ,"./WSL/ExternalOrigin.js" ,"./WSL/Field.js" ,"./WSL/FindHighZombies.js" ,"./WSL/FlattenProtocolExtends.js" ,"./WSL/FlattenedStructOffsetGatherer.js" ,"./WSL/FloatLiteral.js" ,"./WSL/FloatLiteralType.js" ,"./WSL/FoldConstexprs.js" ,"./WSL/ForLoop.js" ,"./WSL/Func.js" ,"./WSL/FuncDef.js" ,"./WSL/FuncInstantiator.js" ,"./WSL/FuncParameter.js" ,"./WSL/FunctionLikeBlock.js" ,"./WSL/HighZombieFinder.js" ,"./WSL/IdentityExpression.js" ,"./WSL/IfStatement.js" ,"./WSL/IndexExpression.js" ,"./WSL/InferTypesForCall.js" ,"./WSL/Inline.js" ,"./WSL/Inliner.js" ,"./WSL/InstantiateImmediates.js" ,"./WSL/IntLiteral.js" ,"./WSL/IntLiteralType.js" ,"./WSL/Intrinsics.js" ,"./WSL/LateChecker.js" ,"./WSL/Lexer.js" ,"./WSL/LexerToken.js" ,"./WSL/LiteralTypeChecker.js" ,"./WSL/LogicalExpression.js" ,"./WSL/LogicalNot.js" ,"./WSL/LoopChecker.js" ,"./WSL/MakeArrayRefExpression.js" ,"./WSL/MakePtrExpression.js" ,"./WSL/NameContext.js" ,"./WSL/NameFinder.js" ,"./WSL/NameResolver.js" ,"./WSL/NativeFunc.js" ,"./WSL/NativeFuncInstance.js" ,"./WSL/NativeType.js" ,"./WSL/NativeTypeInstance.js" ,"./WSL/NormalUsePropertyResolver.js" ,"./WSL/NullLiteral.js" ,"./WSL/NullType.js" ,"./WSL/OriginKind.js" ,"./WSL/OverloadResolutionFailure.js" ,"./WSL/Parse.js" ,"./WSL/Prepare.js" ,"./WSL/Program.js" ,"./WSL/ProgramWithUnnecessaryThingsRemoved.js" ,"./WSL/PropertyResolver.js" ,"./WSL/Protocol.js" ,"./WSL/ProtocolDecl.js" ,"./WSL/ProtocolFuncDecl.js" ,"./WSL/ProtocolRef.js" ,"./WSL/PtrType.js" ,"./WSL/ReadModifyWriteExpression.js" ,"./WSL/RecursionChecker.js" ,"./WSL/RecursiveTypeChecker.js" ,"./WSL/ResolveNames.js" ,"./WSL/ResolveOverloadImpl.js" ,"./WSL/ResolveProperties.js" ,"./WSL/ResolveTypeDefs.js" ,"./WSL/Return.js" ,"./WSL/ReturnChecker.js" ,"./WSL/ReturnException.js" ,"./WSL/StandardLibrary.js" ,"./WSL/StatementCloner.js" ,"./WSL/StructLayoutBuilder.js" ,"./WSL/StructType.js" ,"./WSL/Substitution.js" ,"./WSL/SwitchCase.js" ,"./WSL/SwitchStatement.js" ,"./WSL/SynthesizeEnumFunctions.js" ,"./WSL/SynthesizeStructAccessors.js" ,"./WSL/TrapStatement.js" ,"./WSL/TypeDef.js" ,"./WSL/TypeDefResolver.js" ,"./WSL/TypeOrVariableRef.js" ,"./WSL/TypeParameterRewriter.js" ,"./WSL/TypeRef.js" ,"./WSL/TypeVariable.js" ,"./WSL/TypeVariableTracker.js" ,"./WSL/TypedValue.js" ,"./WSL/UintLiteral.js" ,"./WSL/UintLiteralType.js" ,"./WSL/UnificationContext.js" ,"./WSL/UnreachableCodeChecker.js" ,"./WSL/VariableDecl.js" ,"./WSL/VariableRef.js" ,"./WSL/VisitingSet.js" ,"./WSL/WSyntaxError.js" ,"./WSL/WTrapError.js" ,"./WSL/WTypeError.js" ,"./WSL/WhileLoop.js" ,"./WSL/WrapChecker.js", "./WSL/Test.js"], - tags: ["WSL"], + tags: ["Default", "WSL"], }), // 8bitbench new WasmEMCCBenchmark({ @@ -2178,7 +2215,7 @@ let BENCHMARKS = [ }, iterations: 15, worstCaseCount: 2, - tags: ["Wasm"], + tags: ["Default", "Wasm"], }), // zlib-wasm new WasmEMCCBenchmark({ @@ -2191,7 +2228,7 @@ let BENCHMARKS = [ wasmBinary: "./wasm/zlib/build/zlib.wasm", }, iterations: 40, - tags: ["Wasm"], + tags: ["Default", "Wasm"], }), // .NET new AsyncBenchmark({ @@ -2256,7 +2293,7 @@ for (const test of SUNSPIDER_TESTS) { files: [ `./SunSpider/${test}.js` ], - tags: ["SunSpider"], + tags: ["Default", "SunSpider"], })); } @@ -2281,7 +2318,7 @@ for (const name of WTB_TESTS) { ], iterations: 5, worstCaseCount: 1, - tags: ["WTB"], + tags: ["Default", "WTB"], })); } @@ -2290,12 +2327,14 @@ const benchmarksByName = new Map(); const benchmarksByTag = new Map(); for (const benchmark of BENCHMARKS) { - const name = benchmark.name; + const name = benchmark.name.toLowerCase(); if (benchmarksByName.has(name)) throw new Error(`Duplicate benchmark with name "${name}}"`); else benchmarksByName.set(name, benchmark); + + benchmark.tags.add("all"); for (const tag of benchmark.tags) { if (benchmarksByTag.has(tag)) @@ -2307,43 +2346,6 @@ for (const benchmark of BENCHMARKS) { this.JetStream = new Driver(); -function enableBenchmarks(benchmarks, forceEnable = false) -{ - for (let benchmark of benchmarks) { - if (!forceEnable && benchmark.disabledByDefault) - return; - - JetStream.addBenchmark(benchmark); - } -} - -function enableBenchmarksByName(name) -{ - const benchmark = benchmarksByName.get(name); - - if (!benchmark) - throw new Error(`Couldn't find benchmark named "${name}"`); - - // We only use this for test lists. - JetStream.addBenchmark(benchmark); -} - -function enableBenchmarksByTag(tag, forceEnable = false) -{ - const benchmarks = benchmarksByTag.get(tag); - - if (!benchmarks) { - const validTags = Array.from(benchmarksByTag.keys()).join(", "); - throw new Error(`Couldn't find tag named: ${tag}.\n Choices are ${validTags}`); - } - - for (const benchmark of benchmarks) { - if (!forceEnable && benchmark.disabledByDefault) - continue; - - JetStream.addBenchmark(benchmark); - } -} function processTestList(testList) { @@ -2354,108 +2356,24 @@ function processTestList(testList) else benchmarkNames = testList.split(/[\s,]/); - const forceEnable = true; - for (const name of benchmarkNames) { + for (let name of benchmarkNames) { + name = name.toLowerCase(); if (benchmarksByTag.has(name)) - enableBenchmarksByTag(name, forceEnable); + globalThis.JetStream.enableBenchmarksByTag(name); else - enableBenchmarksByName(name); + globalThis.JetStream.enableBenchmarksByName(name); } } -let runOctane = true; -let runARES = true; -let runWSL = true; -let runRexBench = true; -let runWTB = true; -let runSunSpider = true; -let runBigIntNoble = true; -let runBigIntMisc = true; -let runProxy = true; -let runClassFields = true; -let runGenerators = true; -let runSimple = true; -let runCDJS = true; -let runWorkerTests = !!isInBrowser; -let runSeaMonster = true; -let runCodeLoad = true; -let runWasm = true; -if (typeof WebAssembly === "undefined") - runWasm = false; - -if (false) { - runOctane = false; - runARES = false; - runWSL = false; - runRexBench = false; - runWTB = false; - runSunSpider = false; - runBigIntNoble = false; - runBigIntMisc = false; - runProxy = false; - runClassFields = false; - runGenerators = false; - runSimple = false; - runCDJS = false; - runWorkerTests = false; - runSeaMonster = false; - runCodeLoad = false; - runWasm = false; -} +const defaultDisabledTags = []; +// FIXME: add better support to run Worker tests in shells. +if (!isInBrowser) + defaultDisabledTags.push("WorkerTests"); if (typeof testList !== "undefined") { processTestList(testList); } else if (customTestList.length) { processTestList(customTestList); } else { - if (runARES) - enableBenchmarksByTag("ARES"); - - if (runCDJS) - enableBenchmarksByTag("CDJS"); - - if (runCodeLoad) - enableBenchmarksByTag("CodeLoad"); - - if (runOctane) - enableBenchmarksByTag("Octane"); - - if (runRexBench) - enableBenchmarksByTag("RexBench"); - - if (runSeaMonster) - enableBenchmarksByTag("SeaMonster"); - - if (runSimple) - enableBenchmarksByTag("Simple"); - - if (runSunSpider) - enableBenchmarksByTag("SunSpider"); - - if (runBigIntNoble) - enableBenchmarksByTag("BigIntNoble"); - - if (runBigIntMisc) - enableBenchmarksByTag("BigIntMisc"); - - if (runProxy) - enableBenchmarksByTag("Proxy"); - - if (runClassFields) - enableBenchmarksByTag("ClassFields"); - - if (runGenerators) - enableBenchmarksByTag("Generators"); - - if (runWasm) - enableBenchmarksByTag("Wasm"); - - if (runWorkerTests) - enableBenchmarksByTag("WorkerTests"); - - if (runWSL) - enableBenchmarksByTag("WSL"); - - if (runWTB) - enableBenchmarksByTag("WTB"); + globalThis.JetStream.enableBenchmarksByTag("Default", defaultDisabledTags) } diff --git a/tests/unit-tests.js b/tests/unit-tests.js index 29fd07b..7260a3f 100644 --- a/tests/unit-tests.js +++ b/tests/unit-tests.js @@ -7,8 +7,60 @@ function assertTrue(condition, message) { } } +function assertFalse(condition, message) { + if (condition) { + throw new Error(message || "Assertion failed"); + } +} + +function assertEquals(actual, expected, message) { + if (actual !== expected) { + throw new Error(message || `Expected ${expected}, but got ${actual}`); + } +} + (function testTagsAreStrings() { for (const benchmark of BENCHMARKS) { benchmark.tags.forEach(tag => assertTrue(typeof(tag) == "string")) } -})(); \ No newline at end of file +})(); + + + +(function testTagsAll() { + for (const benchmark of BENCHMARKS) { + assertTrue(benchmark.tags instanceof Set); + assertTrue(benchmark.tags.size > 0); + assertTrue(benchmark.tags.has("all")); + assertFalse(benchmark.tags.has("All")); + } +})(); + + +(function testDriverBenchmarksOrder() { + const driver = new Driver(); + driver.enableBenchmarksByTag("all"); + assertEquals(driver.benchmarks.size, BENCHMARKS.length); + driver.initializeBenchmarks(); + assertEquals(driver.benchmarks.length, BENCHMARKS.length); + const names = driver.benchmarks.map(b => b.name.toLowerCase()).sort().reverse(); + for (let i = 0; i < names.length; i++) { + assertEquals(driver.benchmarks[i].name.toLowerCase(), names[i]); + } +})(); + + +(function testEnableByTag() { + const driverA = new Driver(); + const driverB = new Driver(); + driverA.enableBenchmarksByTag("Default"); + driverB.enableBenchmarksByTag("default"); + assertTrue(driverA.benchmarks.size > 0); + assertEquals(driverA.benchmarks.size, driverB.benchmarks.size); + const enabledBenchmarkNames = new Set( + Array.from(driverA.benchmarks).map(b => b.name)); + for (const benchmark of BENCHMARKS) { + if (benchmark.tags.has("default")) + assertTrue(enabledBenchmarkNames.has(benchmark.name)); + } +})();