Update custom-main to latest main
6215add877
Change-Id: I2fe6e6a634a406f4c0e5c491b4ff6286ae888175
Reviewed-on: https://chromium-review.googlesource.com/c/external/github.com/WebKit/JetStream/+/7124399
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
This commit is contained in:
parent
0368cebd22
commit
2ca0706159
76 changed files with 112979 additions and 211 deletions
80
.github/workflows/test.yml
vendored
80
.github/workflows/test.yml
vendored
|
|
@ -10,48 +10,86 @@ on:
|
|||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
browser-macos:
|
||||
name: Test Browser on macOS
|
||||
runs-on: macos-latest
|
||||
env:
|
||||
GITHUB_ACTIONS_OUTPUT: ""
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
browser: [chrome, firefox, jsc, safari, spidermonkey, v8]
|
||||
browser: [safari]
|
||||
suite: [default, disabled, main]
|
||||
steps:
|
||||
- name: Extract Week Number
|
||||
run: echo "WEEK_NUMBER=$(date +%W)" >> $GITHUB_ENV
|
||||
|
||||
- name: Install Firefox
|
||||
if: ${{ matrix.browser == 'firefox' }}
|
||||
run: brew install --cask firefox
|
||||
|
||||
- name: Checkout Branch
|
||||
- &checkout-branch
|
||||
name: Checkout Branch
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node
|
||||
- &setup-node
|
||||
name: Setup Node
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: npm
|
||||
|
||||
- name: Install Node Packages
|
||||
- &install-node-packages
|
||||
name: Install Node Packages
|
||||
run: npm ci
|
||||
|
||||
- name: Run Tests
|
||||
run: |
|
||||
echo "Running in $BROWSER"
|
||||
npm run test:${{ matrix.browser }} -- ${{ matrix.suite }}
|
||||
|
||||
browser-linux:
|
||||
name: Test Browser on Linux
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GITHUB_ACTIONS_OUTPUT: ""
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
browser: [chrome, firefox]
|
||||
suite: [default, disabled, main]
|
||||
steps:
|
||||
- *checkout-branch
|
||||
- *setup-node
|
||||
- *install-node-packages
|
||||
- name: Run Tests
|
||||
run: |
|
||||
echo "Running in $BROWSER"
|
||||
npm run test:${{ matrix.browser }} -- ${{ matrix.suite }}
|
||||
shell:
|
||||
name: Test Shell
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GITHUB_ACTIONS_OUTPUT: ""
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
shell: [jsc, spidermonkey, v8]
|
||||
suite: [default, disabled, main]
|
||||
steps:
|
||||
- *checkout-branch
|
||||
- *setup-node
|
||||
- *install-node-packages
|
||||
|
||||
- name: Extract Week Number
|
||||
run: echo "WEEK_NUMBER=$(date +%W)" >> $GITHUB_ENV
|
||||
|
||||
- name: Cache jsvu Binaries
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.jsvu
|
||||
key: ${{ runner.os }}-jsvu-${{ matrix.browser }}-week-${{ env.WEEK_NUMBER }}
|
||||
key: ${{ runner.os }}-jsvu-${{ matrix.shell }}-week-${{ env.WEEK_NUMBER }}
|
||||
|
||||
- name: Run Tests
|
||||
run: |
|
||||
echo "Running in $BROWSER"
|
||||
npm run test:${{ matrix.browser }}
|
||||
|
||||
npm run test:${{ matrix.shell }} -- ${{ matrix.suite }}
|
||||
build:
|
||||
name: Build
|
||||
name: Test Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Branch
|
||||
|
|
@ -59,14 +97,8 @@ jobs:
|
|||
with:
|
||||
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: npm
|
||||
|
||||
- name: Install Node Packages
|
||||
run: npm ci
|
||||
- *setup-node
|
||||
- *install-node-packages
|
||||
|
||||
- name: Run Build
|
||||
run: |
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ if (!isInBrowser && JetStreamParams.prefetchResources) {
|
|||
|
||||
// Load a polyfill for TextEncoder/TextDecoder in shells. Used when
|
||||
// decompressing a prefetched resource and converting it to text.
|
||||
load("./polyfills/fast-text-encoding/1.0.3/text.js");
|
||||
load("./utils/polyfills/fast-text-encoding/1.0.3/text.js");
|
||||
}
|
||||
|
||||
// Used for the promise representing the current benchmark run.
|
||||
|
|
@ -842,8 +842,9 @@ class Benchmark {
|
|||
|
||||
get prerunCode() { return null; }
|
||||
|
||||
|
||||
get preIterationCode() {
|
||||
let code = `benchmark.prepareForNextIteration?.();`;
|
||||
let code = this.prepareForNextIterationCode ;
|
||||
if (this.plan.deterministicRandom)
|
||||
code += `Math.random.__resetSeed();`;
|
||||
|
||||
|
|
@ -853,6 +854,10 @@ class Benchmark {
|
|||
return code;
|
||||
}
|
||||
|
||||
get prepareForNextIterationCode() {
|
||||
return "benchmark.prepareForNextIteration?.();"
|
||||
}
|
||||
|
||||
get postIterationCode() {
|
||||
let code = "";
|
||||
|
||||
|
|
@ -905,8 +910,11 @@ class Benchmark {
|
|||
}
|
||||
if (this.plan.preload) {
|
||||
let preloadCode = "";
|
||||
for (let [ variableName, blobURLOrPath ] of this.preloads)
|
||||
for (let [ variableName, blobURLOrPath ] of this.preloads) {
|
||||
console.assert(variableName?.length > 0, "Invalid preload name.");
|
||||
console.assert(blobURLOrPath?.length > 0, "Invalid preload data.");
|
||||
preloadCode += `JetStream.preload[${JSON.stringify(variableName)}] = "${blobURLOrPath}";\n`;
|
||||
}
|
||||
scripts.add(preloadCode);
|
||||
}
|
||||
|
||||
|
|
@ -1060,8 +1068,8 @@ class Benchmark {
|
|||
|
||||
if (this.plan.preload) {
|
||||
this.preloads = [];
|
||||
for (let prop of Object.getOwnPropertyNames(this.plan.preload)) {
|
||||
promises.push(this.loadBlob("preload", prop, this.plan.preload[prop]).then((blobData) => {
|
||||
for (const [name, resource] of Object.entries(this.plan.preload)) {
|
||||
promises.push(this.loadBlob("preload", name, resource).then((blobData) => {
|
||||
if (!globalThis.allIsGood)
|
||||
return;
|
||||
this.preloads.push([ blobData.prop, blobData.blobURL ]);
|
||||
|
|
@ -1070,7 +1078,7 @@ class Benchmark {
|
|||
// We'll try again later in retryPrefetchResourceForBrowser(). Don't throw an error.
|
||||
if (!this.failedPreloads)
|
||||
this.failedPreloads = { };
|
||||
this.failedPreloads[prop] = true;
|
||||
this.failedPreloads[name] = true;
|
||||
JetStream.counter.failedPreloadResources++;
|
||||
}));
|
||||
}
|
||||
|
|
@ -1127,9 +1135,8 @@ class Benchmark {
|
|||
}
|
||||
|
||||
if (this.plan.preload) {
|
||||
for (const prop of Object.getOwnPropertyNames(this.plan.preload)) {
|
||||
const resource = this.plan.preload[prop];
|
||||
const allDone = await this.retryPrefetchResource("preload", prop, resource);
|
||||
for (const [name, resource] of Object.entries(this.plan.preload)) {
|
||||
const allDone = await this.retryPrefetchResource("preload", name, resource);
|
||||
if (allDone)
|
||||
return true; // All resources loaded, nothing more to do.
|
||||
}
|
||||
|
|
@ -1149,21 +1156,21 @@ class Benchmark {
|
|||
if (!this.plan.preload) {
|
||||
return;
|
||||
}
|
||||
for (let [name, file] of Object.entries(this.plan.preload)) {
|
||||
const compressed = isCompressed(file);
|
||||
for (let [name, resource] of Object.entries(this.plan.preload)) {
|
||||
const compressed = isCompressed(resource);
|
||||
if (compressed && !JetStreamParams.prefetchResources) {
|
||||
file = uncompressedName(file);
|
||||
resource = uncompressedName(resource);
|
||||
}
|
||||
|
||||
if (JetStreamParams.prefetchResources) {
|
||||
let bytes = new Int8Array(read(file, "binary"));
|
||||
let bytes = new Int8Array(read(resource, "binary"));
|
||||
if (compressed) {
|
||||
bytes = zlib.decompress(bytes);
|
||||
}
|
||||
this.shellPrefetchedResources[file] = bytes;
|
||||
this.shellPrefetchedResources[resource] = bytes;
|
||||
}
|
||||
|
||||
this.preloads.push([name, file]);
|
||||
this.preloads.push([name, resource]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1517,6 +1524,10 @@ class AsyncBenchmark extends DefaultBenchmark {
|
|||
return str;
|
||||
}
|
||||
|
||||
get prepareForNextIterationCode() {
|
||||
return "await benchmark.prepareForNextIteration?.();"
|
||||
}
|
||||
|
||||
get runnerCode() {
|
||||
return `
|
||||
async function doRun() {
|
||||
|
|
@ -1753,10 +1764,10 @@ class WasmLegacyBenchmark extends Benchmark {
|
|||
}
|
||||
|
||||
str += "};\n";
|
||||
|
||||
const keys = Object.keys(this.plan.preload);
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
str += `JetStream.loadBlob("${keys[i]}", "${this.plan.preload[keys[i]]}", () => {\n`;
|
||||
let preloadCount = 0;
|
||||
for (const [name, resource] of Object.entries(this.plan.preload)) {
|
||||
preloadCount++;
|
||||
str += `JetStream.loadBlob(${JSON.stringify(name)}, "${resource}", () => {\n`;
|
||||
}
|
||||
if (this.plan.async) {
|
||||
str += `doRun().catch((e) => {
|
||||
|
|
@ -1767,7 +1778,7 @@ class WasmLegacyBenchmark extends Benchmark {
|
|||
} else {
|
||||
str += `doRun();`
|
||||
}
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
for (let i = 0; i < preloadCount; ++i) {
|
||||
str += `})`;
|
||||
}
|
||||
str += `;`;
|
||||
|
|
@ -2254,6 +2265,21 @@ let BENCHMARKS = [
|
|||
],
|
||||
tags: ["default", "js", "Proxy"],
|
||||
}),
|
||||
new AsyncBenchmark({
|
||||
name: "mobx-startup",
|
||||
files: [
|
||||
"./utils/StartupBenchmark.js",
|
||||
"./mobx/benchmark.js",
|
||||
],
|
||||
preload: {
|
||||
// Debug Sources for nicer profiling.
|
||||
// BUNDLE: "./mobx/dist/bundle.es6.js",
|
||||
BUNDLE: "./mobx/dist/bundle.es6.min.js",
|
||||
},
|
||||
tags: ["default", "js", "mobx", "startup", "es6"],
|
||||
iterations: 30,
|
||||
worstCaseCount: 3,
|
||||
}),
|
||||
new AsyncBenchmark({
|
||||
name: "jsdom-d3-startup",
|
||||
files: [
|
||||
|
|
@ -2432,7 +2458,7 @@ let BENCHMARKS = [
|
|||
new WasmEMCCBenchmark({
|
||||
name: "sqlite3-wasm",
|
||||
files: [
|
||||
"./polyfills/fast-text-encoding/1.0.3/text.js",
|
||||
"./utils/polyfills/fast-text-encoding/1.0.3/text.js",
|
||||
"./sqlite3/benchmark.js",
|
||||
"./sqlite3/build/jswasm/speedtest1.js",
|
||||
],
|
||||
|
|
@ -2497,7 +2523,7 @@ let BENCHMARKS = [
|
|||
new AsyncBenchmark({
|
||||
name: "transformersjs-bert-wasm",
|
||||
files: [
|
||||
"./polyfills/fast-text-encoding/1.0.3/text.js",
|
||||
"./utils/polyfills/fast-text-encoding/1.0.3/text.js",
|
||||
"./transformersjs/benchmark.js",
|
||||
"./transformersjs/task-bert.js",
|
||||
],
|
||||
|
|
@ -2519,7 +2545,7 @@ let BENCHMARKS = [
|
|||
new AsyncBenchmark({
|
||||
name: "transformersjs-whisper-wasm",
|
||||
files: [
|
||||
"./polyfills/fast-text-encoding/1.0.3/text.js",
|
||||
"./utils/polyfills/fast-text-encoding/1.0.3/text.js",
|
||||
"./transformersjs/benchmark.js",
|
||||
"./transformersjs/task-whisper.js",
|
||||
],
|
||||
|
|
@ -2542,7 +2568,7 @@ let BENCHMARKS = [
|
|||
iterations: 5,
|
||||
worstCaseCount: 1,
|
||||
allowUtf16: true,
|
||||
tags: ["default", "Wasm", "transformersjs"],
|
||||
tags: ["Wasm", "transformersjs"],
|
||||
}),
|
||||
new WasmLegacyBenchmark({
|
||||
name: "tfjs-wasm",
|
||||
|
|
@ -2603,6 +2629,68 @@ let BENCHMARKS = [
|
|||
allowUtf16: true,
|
||||
tags: ["default", "Wasm"],
|
||||
}),
|
||||
new AsyncBenchmark({
|
||||
name: "babylonjs-startup-es5",
|
||||
files: [
|
||||
"./utils/StartupBenchmark.js",
|
||||
"./babylonjs/benchmark/startup.js",
|
||||
],
|
||||
preload: {
|
||||
BUNDLE: "./babylonjs/dist/bundle.es5.min.js",
|
||||
},
|
||||
arguments: {
|
||||
expectedCacheCommentCount: 23988,
|
||||
},
|
||||
tags: ["startup", "js", "class", "es5", "babylonjs"],
|
||||
iterations: 10,
|
||||
}),
|
||||
new AsyncBenchmark({
|
||||
name: "babylonjs-startup-es6",
|
||||
files: [
|
||||
"./utils/StartupBenchmark.js",
|
||||
"./babylonjs/benchmark/startup.js",
|
||||
],
|
||||
preload: {
|
||||
BUNDLE: "./babylonjs/dist/bundle.es6.min.js",
|
||||
},
|
||||
arguments: {
|
||||
expectedCacheCommentCount: 21222,
|
||||
},
|
||||
tags: ["Default", "js", "startup", "class", "es6", "babylonjs"],
|
||||
iterations: 10,
|
||||
}),
|
||||
new AsyncBenchmark({
|
||||
name: "babylonjs-scene-es5",
|
||||
files: [
|
||||
// Use non-minified sources for easier profiling:
|
||||
// "./babylonjs/dist/bundle.es5.js",
|
||||
"./babylonjs/dist/bundle.es5.min.js",
|
||||
"./babylonjs/benchmark/scene.js",
|
||||
],
|
||||
preload: {
|
||||
PARTICLES_BLOB: "./babylonjs/data/particles.json",
|
||||
PIRATE_FORT_BLOB: "./babylonjs/data/pirateFort.glb",
|
||||
CANNON_BLOB: "./babylonjs/data/cannon.glb",
|
||||
},
|
||||
tags: ["scene", "js", "es5", "babylonjs"],
|
||||
iterations: 5,
|
||||
}),
|
||||
new AsyncBenchmark({
|
||||
name: "babylonjs-scene-es6",
|
||||
files: [
|
||||
// Use non-minified sources for easier profiling:
|
||||
// "./babylonjs/dist/bundle.es6.js",
|
||||
"./babylonjs/dist/bundle.es6.min.js",
|
||||
"./babylonjs/benchmark/scene.js",
|
||||
],
|
||||
preload: {
|
||||
PARTICLES_BLOB: "./babylonjs/data/particles.json",
|
||||
PIRATE_FORT_BLOB: "./babylonjs/data/pirateFort.glb",
|
||||
CANNON_BLOB: "./babylonjs/data/cannon.glb",
|
||||
},
|
||||
tags: ["Default", "js", "scene", "es6", "babylonjs"],
|
||||
iterations: 5,
|
||||
}),
|
||||
// WorkerTests
|
||||
new AsyncBenchmark({
|
||||
name: "bomb-workers",
|
||||
|
|
@ -2812,7 +2900,7 @@ let BENCHMARKS = [
|
|||
new WasmEMCCBenchmark({
|
||||
name: "8bitbench-wasm",
|
||||
files: [
|
||||
"./polyfills/fast-text-encoding/1.0.3/text.js",
|
||||
"./utils/polyfills/fast-text-encoding/1.0.3/text.js",
|
||||
"./8bitbench/build/rust/pkg/emu_bench.js",
|
||||
"./8bitbench/benchmark.js",
|
||||
],
|
||||
|
|
|
|||
34
babylonjs/README.md
Normal file
34
babylonjs/README.md
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# Babylon.js Benchmarks for JetStream
|
||||
|
||||
This project contains two benchmarks for testing the performance of the Babylon.js 3D engine.
|
||||
|
||||
## Build Instructions
|
||||
|
||||
```bash
|
||||
# install required node packages.
|
||||
npm ci
|
||||
# build the workload, output is ./dist
|
||||
npm run build
|
||||
```
|
||||
|
||||
## Workloads
|
||||
|
||||
There are two distinct workloads in this benchmark suite:
|
||||
|
||||
### 1. Startup Workload
|
||||
|
||||
This benchmark measures the time it takes for the Babylon.js engine to initialize. It evaluates a large, bundled source file and measures the time to parse the code and execute a simple test. This workload is primarily focused on parse and startup time.
|
||||
|
||||
To run this benchmark in node for testing:
|
||||
```bash
|
||||
npm run test:startup
|
||||
```
|
||||
|
||||
### 2. Scene Workload
|
||||
|
||||
This benchmark measures the rendering performance of a complex 3D scene. It loads 3D models (`.glb` files), animations, and particle systems, and then renders the scene for a number of frames.
|
||||
|
||||
To run this benchmark in node for testing:
|
||||
```bash
|
||||
npm run test:scene
|
||||
```
|
||||
25
babylonjs/benchmark/scene-node.mjs
Normal file
25
babylonjs/benchmark/scene-node.mjs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { runComplexScene } from "../src/babylon-js-benchmark.mjs";
|
||||
import { promises as fs } from "fs";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const fortPath = path.resolve(__dirname, "../data/pirateFort.glb");
|
||||
const cannonPath = path.resolve(__dirname, "../data/cannon.glb");
|
||||
const particlePath = path.resolve(__dirname, "../data/particles.json");
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const fortBuffer = await fs.readFile(fortPath);
|
||||
const cannonBuffer = await fs.readFile(cannonPath);
|
||||
const particleData = JSON.parse(await fs.readFile(particlePath, "utf-8"))
|
||||
const {classNames, cameraRotationLength} = await runComplexScene(fortBuffer, cannonBuffer, particleData, 1000);
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
console.error(e.stack);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
53
babylonjs/benchmark/scene.js
Normal file
53
babylonjs/benchmark/scene.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// console.log = () => {};
|
||||
|
||||
globalThis.setTimeout = (callback, timeout) => callback();
|
||||
globalThis.requestAnimationFrame = (callback) => callback();
|
||||
|
||||
// JetStream benchmark.
|
||||
class Benchmark {
|
||||
iterationCount = 0;
|
||||
preloaded = {
|
||||
fortData: null,
|
||||
cannonData: null,
|
||||
particlesJson: null,
|
||||
};
|
||||
|
||||
constructor(iterationCount) {
|
||||
this.iterationCount = iterationCount;
|
||||
}
|
||||
|
||||
async init() {
|
||||
const [fort, cannon, particles] = await Promise.all([
|
||||
JetStream.getBinary(JetStream.preload.PIRATE_FORT_BLOB),
|
||||
JetStream.getBinary(JetStream.preload.CANNON_BLOB),
|
||||
JetStream.getString(JetStream.preload.PARTICLES_BLOB),
|
||||
]);
|
||||
this.preloaded.fortData = fort;
|
||||
this.preloaded.cannonData = cannon;
|
||||
this.preloaded.particlesJson = JSON.parse(particles);
|
||||
}
|
||||
|
||||
async runIteration() {
|
||||
const {classNames, cameraRotationLength} = await BabylonJSBenchmark.runComplexScene(
|
||||
this.preloaded.fortData,
|
||||
this.preloaded.cannonData,
|
||||
this.preloaded.particlesJson,
|
||||
100
|
||||
);
|
||||
const lastResult = {
|
||||
classNames,
|
||||
cameraRotationLength
|
||||
};
|
||||
this.validateIteration(lastResult);
|
||||
}
|
||||
|
||||
validateIteration(lastResult) {
|
||||
this.expect("this.lastResult.classNames.length", lastResult.classNames.length, 2135);
|
||||
this.expect("this.lastResult.cameraRotationLength", lastResult.cameraRotationLength, 0);
|
||||
}
|
||||
|
||||
expect(name, value, expected) {
|
||||
if (value != expected)
|
||||
throw new Error(`Expected ${name} to be ${expected}, but got ${value}`);
|
||||
}
|
||||
}
|
||||
3
babylonjs/benchmark/startup-node.mjs
Normal file
3
babylonjs/benchmark/startup-node.mjs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import { runTest } from "../src/babylon-js-benchmark.mjs";
|
||||
|
||||
console.log(runTest());
|
||||
83
babylonjs/benchmark/startup.js
Normal file
83
babylonjs/benchmark/startup.js
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (C) 2025 Apple Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// console.log = () => {};
|
||||
|
||||
class Benchmark extends StartupBenchmark {
|
||||
iteration = 0;
|
||||
|
||||
constructor({iterationCount, expectedCacheCommentCount}) {
|
||||
super({
|
||||
iterationCount,
|
||||
codeReuseCount: 2,
|
||||
expectedCacheCommentCount,
|
||||
});
|
||||
}
|
||||
|
||||
runIteration() {
|
||||
const sourceCode = this.iterationSourceCodes[this.iteration];
|
||||
if (!sourceCode)
|
||||
throw new Error(`Could not find source for iteration ${this.iteration}`);
|
||||
// Module in sourceCode it assigned to the ClassStartupTest variable.
|
||||
let BabylonJSBenchmark;
|
||||
|
||||
// let initStart = performance.now();
|
||||
eval(sourceCode);
|
||||
// const runStart = performance.now();
|
||||
|
||||
const { classNames, cameraRotationLength } = BabylonJSBenchmark.runTest(30);
|
||||
const lastResult = {
|
||||
classNames,
|
||||
cameraRotationLength,
|
||||
};
|
||||
this.validateIteration(lastResult)
|
||||
// const end = performance.now();
|
||||
// const loadTime = runStart - initStart;
|
||||
// const runTime = end - runStart;
|
||||
// For local debugging:
|
||||
// print(`Iteration ${this.iteration}:`);
|
||||
// print(` Load time: ${loadTime.toFixed(2)}ms`);
|
||||
// print(` Render time: ${runTime.toFixed(2)}ms`);
|
||||
this.iteration++;
|
||||
}
|
||||
|
||||
validateIteration(lastResult) {
|
||||
this.expect(
|
||||
"this.lastResult.classNames.length",
|
||||
lastResult.classNames.length,
|
||||
2135
|
||||
);
|
||||
this.expect(
|
||||
"this.lastResult.cameraRotationLength",
|
||||
Math.round(lastResult.cameraRotationLength * 1000),
|
||||
464
|
||||
);
|
||||
}
|
||||
|
||||
expect(name, value, expected) {
|
||||
if (value != expected)
|
||||
throw new Error(`Expected ${name} to be ${expected}, but got ${value}`);
|
||||
}
|
||||
}
|
||||
30
babylonjs/build/build.mjs
Normal file
30
babylonjs/build/build.mjs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const SNIPPET_URL = 'https://snippet.babylonjs.com/LCBQ5Y/6';
|
||||
const RAW_SNIPPET_PATH = path.resolve(__dirname, '../data/snippets.LCBQ5Y.raw.json');
|
||||
const PARTICLES_PATH = path.resolve(__dirname, '../data/particles.json');
|
||||
|
||||
async function main() {
|
||||
const response = await fetch(SNIPPET_URL);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to download file: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
const snippetJson = await response.json();
|
||||
|
||||
console.log(`Saving raw snippet: ${RAW_SNIPPET_PATH}`);
|
||||
fs.writeFileSync(RAW_SNIPPET_PATH, JSON.stringify(snippetJson));
|
||||
|
||||
const jsonPayload = JSON.parse(snippetJson.jsonPayload);
|
||||
const particleSystem = JSON.parse(jsonPayload.particleSystem);
|
||||
|
||||
console.log(`Saving particles: ${PARTICLES_PATH}:`);
|
||||
fs.writeFileSync(PARTICLES_PATH, JSON.stringify(particleSystem, null, 2));
|
||||
}
|
||||
|
||||
main();
|
||||
395
babylonjs/data/LICENSE.txt
Normal file
395
babylonjs/data/LICENSE.txt
Normal file
|
|
@ -0,0 +1,395 @@
|
|||
Attribution 4.0 International
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
||||
does not provide legal services or legal advice. Distribution of
|
||||
Creative Commons public licenses does not create a lawyer-client or
|
||||
other relationship. Creative Commons makes its licenses and related
|
||||
information available on an "as-is" basis. Creative Commons gives no
|
||||
warranties regarding its licenses, any material licensed under their
|
||||
terms and conditions, or any related information. Creative Commons
|
||||
disclaims all liability for damages resulting from their use to the
|
||||
fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and
|
||||
conditions that creators and other rights holders may use to share
|
||||
original works of authorship and other material subject to copyright
|
||||
and certain other rights specified in the public license below. The
|
||||
following considerations are for informational purposes only, are not
|
||||
exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are
|
||||
intended for use by those authorized to give the public
|
||||
permission to use material in ways otherwise restricted by
|
||||
copyright and certain other rights. Our licenses are
|
||||
irrevocable. Licensors should read and understand the terms
|
||||
and conditions of the license they choose before applying it.
|
||||
Licensors should also secure all rights necessary before
|
||||
applying our licenses so that the public can reuse the
|
||||
material as expected. Licensors should clearly mark any
|
||||
material not subject to the license. This includes other CC-
|
||||
licensed material, or material used under an exception or
|
||||
limitation to copyright. More considerations for licensors:
|
||||
wiki.creativecommons.org/Considerations_for_licensors
|
||||
|
||||
Considerations for the public: By using one of our public
|
||||
licenses, a licensor grants the public permission to use the
|
||||
licensed material under specified terms and conditions. If
|
||||
the licensor's permission is not necessary for any reason--for
|
||||
example, because of any applicable exception or limitation to
|
||||
copyright--then that use is not regulated by the license. Our
|
||||
licenses grant only permissions under copyright and certain
|
||||
other rights that a licensor has authority to grant. Use of
|
||||
the licensed material may still be restricted for other
|
||||
reasons, including because others have copyright or other
|
||||
rights in the material. A licensor may make special requests,
|
||||
such as asking that all changes be marked or described.
|
||||
Although not required by our licenses, you are encouraged to
|
||||
respect those requests where reasonable. More_considerations
|
||||
for the public:
|
||||
wiki.creativecommons.org/Considerations_for_licensees
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Attribution 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution 4.0 International Public License ("Public License"). To the
|
||||
extent this Public License may be interpreted as a contract, You are
|
||||
granted the Licensed Rights in consideration of Your acceptance of
|
||||
these terms and conditions, and the Licensor grants You such rights in
|
||||
consideration of benefits the Licensor receives from making the
|
||||
Licensed Material available under these terms and conditions.
|
||||
|
||||
|
||||
Section 1 -- Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright
|
||||
and Similar Rights in Your contributions to Adapted Material in
|
||||
accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
d. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
e. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
f. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
g. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
h. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
i. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
j. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
k. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part; and
|
||||
|
||||
b. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified
|
||||
form), You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
4. If You Share Adapted Material You produce, the Adapter's
|
||||
License You apply must not prevent recipients of the Adapted
|
||||
Material from complying with this Public License.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material; and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons is not a party to its public
|
||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
||||
its public licenses to material it publishes and in those instances
|
||||
will be considered the “Licensor.” The text of the Creative Commons
|
||||
public licenses is dedicated to the public domain under the CC0 Public
|
||||
Domain Dedication. Except for the limited purpose of indicating that
|
||||
material is shared under a Creative Commons public license or as
|
||||
otherwise permitted by the Creative Commons policies published at
|
||||
creativecommons.org/policies, Creative Commons does not authorize the
|
||||
use of the trademark "Creative Commons" or any other trademark or logo
|
||||
of Creative Commons without its prior written consent including,
|
||||
without limitation, in connection with any unauthorized modifications
|
||||
to any of its public licenses or any other arrangements,
|
||||
understandings, or agreements concerning use of licensed material. For
|
||||
the avoidance of doubt, this paragraph does not form part of the
|
||||
public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
||||
BIN
babylonjs/data/cannon.glb
Normal file
BIN
babylonjs/data/cannon.glb
Normal file
Binary file not shown.
1
babylonjs/data/particles.LCBQ5Y.json
Normal file
1
babylonjs/data/particles.LCBQ5Y.json
Normal file
File diff suppressed because one or more lines are too long
191
babylonjs/data/particles.json
Normal file
191
babylonjs/data/particles.json
Normal file
File diff suppressed because one or more lines are too long
BIN
babylonjs/data/pirateFort.glb
Normal file
BIN
babylonjs/data/pirateFort.glb
Normal file
Binary file not shown.
1
babylonjs/data/snippets.LCBQ5Y.raw.json
Normal file
1
babylonjs/data/snippets.LCBQ5Y.raw.json
Normal file
File diff suppressed because one or more lines are too long
8935
babylonjs/dist/LICENSE.txt
vendored
Normal file
8935
babylonjs/dist/LICENSE.txt
vendored
Normal file
File diff suppressed because it is too large
Load diff
50514
babylonjs/dist/bundle.es5.min.js
vendored
Normal file
50514
babylonjs/dist/bundle.es5.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
babylonjs/dist/bundle.es5.min.js.map
vendored
Normal file
1
babylonjs/dist/bundle.es5.min.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
42475
babylonjs/dist/bundle.es6.min.js
vendored
Normal file
42475
babylonjs/dist/bundle.es6.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
babylonjs/dist/bundle.es6.min.js.map
vendored
Normal file
1
babylonjs/dist/bundle.es6.min.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
7863
babylonjs/package-lock.json
generated
Normal file
7863
babylonjs/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
29
babylonjs/package.json
Normal file
29
babylonjs/package.json
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "babylon-startup",
|
||||
"version": "1.0.0",
|
||||
"main": "benchmark-node.mjs",
|
||||
"scripts": {
|
||||
"test:startup": "babel-node benchmark/startup-node.mjs",
|
||||
"test:scene": "babel-node benchmark/scene-node.mjs",
|
||||
"clean": "rm -rf dist/*",
|
||||
"build": "webpack",
|
||||
"build:data": "node build/build.mjs",
|
||||
"build:dev": "webpack --mode development"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.28.3",
|
||||
"@babel/node": "^7.28.0",
|
||||
"@babel/preset-env": "^7.28.3",
|
||||
"@babylonjs/core": "^8.23.0",
|
||||
"@babylonjs/loaders": "^8.23.1",
|
||||
"ammojs-typed": "^1.0.6",
|
||||
"assert": "^2.1.0",
|
||||
"babel-loader": "^10.0.0",
|
||||
"generate-license-file-webpack-plugin": "^4.0.0",
|
||||
"path-browserify": "^1.0.1",
|
||||
"terser-webpack-plugin": "^5.3.14",
|
||||
"webpack": "^5.101.1",
|
||||
"webpack-cli": "^6.0.1",
|
||||
"@dapplets/unicode-escape-webpack-plugin": "^0.1.1"
|
||||
}
|
||||
}
|
||||
293
babylonjs/src/babylon-js-benchmark.mjs
Normal file
293
babylonjs/src/babylon-js-benchmark.mjs
Normal file
|
|
@ -0,0 +1,293 @@
|
|||
import * as BABYLON from "@babylonjs/core";
|
||||
import "@babylonjs/loaders";
|
||||
import Ammo from "ammojs-typed";
|
||||
|
||||
export function runTest(frames = 10) {
|
||||
const classNames = Object.keys(BABYLON);
|
||||
BABYLON.Logger.LogLevels = BABYLON.Logger.NoneLogLevel;
|
||||
const engine = new BABYLON.NullEngine();
|
||||
const scene = createScene(engine);
|
||||
for (let i = 0; i < frames; i++) {
|
||||
scene.render();
|
||||
}
|
||||
return {
|
||||
classNames,
|
||||
cameraRotationLength: scene.cameras[0].rotation.length(),
|
||||
};
|
||||
}
|
||||
|
||||
function createScene(engine) {
|
||||
const scene = new BABYLON.Scene(engine);
|
||||
scene.useConstantAnimationDeltaTime = true;
|
||||
const camera = new BABYLON.FreeCamera(
|
||||
"camera1",
|
||||
new BABYLON.Vector3(0, 5, -10),
|
||||
scene
|
||||
);
|
||||
camera.setTarget(BABYLON.Vector3.Zero());
|
||||
const light = new BABYLON.HemisphericLight(
|
||||
"light1",
|
||||
new BABYLON.Vector3(0, 1, 0),
|
||||
scene
|
||||
);
|
||||
const sphere = BABYLON.MeshBuilder.CreateSphere(
|
||||
"sphere1",
|
||||
{ segments: 16, diameter: 2, sideOrientation: BABYLON.Mesh.FRONTSIDE },
|
||||
scene
|
||||
);
|
||||
sphere.position.y = 1;
|
||||
const ground = BABYLON.MeshBuilder.CreateGround(
|
||||
"ground1",
|
||||
{ width: 6, height: 6, subdivisions: 2, updatable: false },
|
||||
scene
|
||||
);
|
||||
return scene;
|
||||
}
|
||||
|
||||
export async function runComplexScene(
|
||||
fortData,
|
||||
cannonData,
|
||||
particleData,
|
||||
frames = 10
|
||||
) {
|
||||
const classNames = Object.keys(BABYLON);
|
||||
BABYLON.Logger.LogLevels = BABYLON.Logger.NoneLogLevel;
|
||||
const engine = new BABYLON.NullEngine({
|
||||
deterministicLockstep: true,
|
||||
});
|
||||
const scene = await createComplexScene(
|
||||
engine,
|
||||
fortData,
|
||||
cannonData,
|
||||
particleData
|
||||
);
|
||||
for (let i = 0; i < frames; i++) {
|
||||
scene.animate();
|
||||
scene.render();
|
||||
}
|
||||
// Leak state to the outside.
|
||||
return {
|
||||
classNames,
|
||||
cameraRotationLength: scene.cameras[0].rotation.length(),
|
||||
};
|
||||
}
|
||||
|
||||
async function createComplexScene(engine, fortData, cannonData, particleData) {
|
||||
// Source:
|
||||
// - https://www.babylonjs.com/featureDemos/
|
||||
// - https://playground.babylonjs.com/#C21DGD#2
|
||||
const scene = new BABYLON.Scene(engine);
|
||||
scene.useConstantAnimationDeltaTime = true;
|
||||
scene.clearColor = new BABYLON.Color3(0.31, 0.48, 0.64);
|
||||
let camera = new BABYLON.ArcRotateCamera(
|
||||
"camera",
|
||||
BABYLON.Tools.ToRadians(125),
|
||||
BABYLON.Tools.ToRadians(70),
|
||||
25,
|
||||
new BABYLON.Vector3(0, 3, 0),
|
||||
scene
|
||||
);
|
||||
camera.lowerRadiusLimit = 10;
|
||||
const ammo = await Ammo();
|
||||
scene.enablePhysics(
|
||||
new BABYLON.Vector3(0, -9.8, 0),
|
||||
new BABYLON.AmmoJSPlugin(true, ammo)
|
||||
);
|
||||
let cannonAnimationPairings = {};
|
||||
let cannonReadyToPlay = {};
|
||||
|
||||
//create a cannonBall template to clone from, set it's visibility to off.
|
||||
let cannonBall = BABYLON.MeshBuilder.CreateSphere(
|
||||
"cannonBall",
|
||||
{ diameter: 0.3 },
|
||||
scene
|
||||
);
|
||||
let cannonBallMat = new BABYLON.StandardMaterial("cannonBallMaterial", scene);
|
||||
cannonBallMat.diffuseColor = BABYLON.Color3.Black();
|
||||
cannonBallMat.specularPower = 256;
|
||||
cannonBall.material = cannonBallMat;
|
||||
cannonBall.visibility = false;
|
||||
|
||||
//create a large box far underneath the tower, that will act as a trigger to destroy the cannonballs.
|
||||
let killBox = BABYLON.MeshBuilder.CreateBox(
|
||||
"killBox",
|
||||
{ width: 400, depth: 400, height: 4 },
|
||||
scene
|
||||
);
|
||||
killBox.position = new BABYLON.Vector3(0, -50, 0);
|
||||
killBox.visibility = 0;
|
||||
|
||||
const pirateFortImport = await BABYLON.ImportMeshAsync(fortData, scene, {
|
||||
pluginExtension: ".glb",
|
||||
});
|
||||
pirateFortImport.meshes[0].name = "pirateFort";
|
||||
scene.getMeshByName("sea").material.needDepthPrePass = true;
|
||||
scene.getLightByName("Sun").intensity = 12;
|
||||
|
||||
//Load the cannon model and create clones
|
||||
const cannonImportResult = await BABYLON.ImportMeshAsync(cannonData, scene, {
|
||||
pluginExtension: ".glb",
|
||||
});
|
||||
//remove the top level root node
|
||||
let cannon = cannonImportResult.meshes[0].getChildren()[0];
|
||||
cannon.setParent(null);
|
||||
cannonImportResult.meshes[0].dispose();
|
||||
|
||||
//set the metadata of each mesh to filter on later
|
||||
let cannonMeshes = cannon.getChildMeshes();
|
||||
for (let i = 0; i < cannonMeshes.length; i++) {
|
||||
cannonMeshes[i].metadata = "cannon";
|
||||
}
|
||||
|
||||
const importedAnimGroups = cannonImportResult.animationGroups;
|
||||
|
||||
//loop through all imported animation groups and copy the animation curve data to an array.
|
||||
let animations = [];
|
||||
for (let i = 0; i < importedAnimGroups.length; i++) {
|
||||
importedAnimGroups[i].stop();
|
||||
animations.push(importedAnimGroups[i].targetedAnimations[0].animation);
|
||||
importedAnimGroups[i].dispose();
|
||||
}
|
||||
|
||||
//create a new animation group and add targeted animations based on copied curve data from the "animations" array.
|
||||
let cannonAnimGroup = new BABYLON.AnimationGroup("cannonAnimGroup");
|
||||
cannonAnimGroup.addTargetedAnimation(
|
||||
animations[0],
|
||||
cannon.getChildMeshes()[1]
|
||||
);
|
||||
cannonAnimGroup.addTargetedAnimation(
|
||||
animations[1],
|
||||
cannon.getChildMeshes()[0]
|
||||
);
|
||||
|
||||
//create a box for particle emission, position it at the muzzle of the cannon, turn off visibility and parent it to the cannon mesh
|
||||
let particleEmitter = BABYLON.MeshBuilder.CreateBox(
|
||||
"particleEmitter",
|
||||
{ size: 0.05 },
|
||||
scene
|
||||
);
|
||||
particleEmitter.position = new BABYLON.Vector3(0, 0.76, 1.05);
|
||||
particleEmitter.rotation.x = BABYLON.Tools.ToRadians(78.5);
|
||||
particleEmitter.isVisible = false;
|
||||
particleEmitter.setParent(cannon.getChildMeshes()[1]);
|
||||
|
||||
//load particle system from the snippet server and set the emitter to the particleEmitter. Set its stopDuration.
|
||||
const smokeBlast = BABYLON.ParticleSystem.Parse(particleData, scene, "");
|
||||
smokeBlast.emitter = particleEmitter;
|
||||
smokeBlast.targetStopDuration = 0.2;
|
||||
|
||||
//position and rotation data for the placement of the cannon clones
|
||||
let cannonPositionArray = [
|
||||
[
|
||||
new BABYLON.Vector3(0.97, 5.52, 1.79),
|
||||
new BABYLON.Vector3(
|
||||
BABYLON.Tools.ToRadians(0),
|
||||
BABYLON.Tools.ToRadians(0),
|
||||
BABYLON.Tools.ToRadians(180)
|
||||
),
|
||||
],
|
||||
[
|
||||
new BABYLON.Vector3(1.08, 2.32, 3.05),
|
||||
new BABYLON.Vector3(
|
||||
BABYLON.Tools.ToRadians(0),
|
||||
BABYLON.Tools.ToRadians(0),
|
||||
BABYLON.Tools.ToRadians(180)
|
||||
),
|
||||
],
|
||||
[
|
||||
new BABYLON.Vector3(1.46, 2.35, -0.73),
|
||||
new BABYLON.Vector3(
|
||||
BABYLON.Tools.ToRadians(0),
|
||||
BABYLON.Tools.ToRadians(90),
|
||||
BABYLON.Tools.ToRadians(180)
|
||||
),
|
||||
],
|
||||
[
|
||||
new BABYLON.Vector3(1.45, 5.52, -1.66),
|
||||
new BABYLON.Vector3(
|
||||
BABYLON.Tools.ToRadians(0),
|
||||
BABYLON.Tools.ToRadians(90),
|
||||
BABYLON.Tools.ToRadians(180)
|
||||
),
|
||||
],
|
||||
[
|
||||
new BABYLON.Vector3(1.49, 8.69, -0.35),
|
||||
new BABYLON.Vector3(
|
||||
BABYLON.Tools.ToRadians(0),
|
||||
BABYLON.Tools.ToRadians(90),
|
||||
BABYLON.Tools.ToRadians(180)
|
||||
),
|
||||
],
|
||||
[
|
||||
new BABYLON.Vector3(-1.37, 8.69, -0.39),
|
||||
new BABYLON.Vector3(
|
||||
BABYLON.Tools.ToRadians(0),
|
||||
BABYLON.Tools.ToRadians(-90),
|
||||
BABYLON.Tools.ToRadians(180)
|
||||
),
|
||||
],
|
||||
[
|
||||
new BABYLON.Vector3(0.58, 4, -2.18),
|
||||
new BABYLON.Vector3(
|
||||
BABYLON.Tools.ToRadians(0),
|
||||
BABYLON.Tools.ToRadians(180),
|
||||
BABYLON.Tools.ToRadians(180)
|
||||
),
|
||||
],
|
||||
[
|
||||
new BABYLON.Vector3(1.22, 8.69, -2.5),
|
||||
new BABYLON.Vector3(
|
||||
BABYLON.Tools.ToRadians(0),
|
||||
BABYLON.Tools.ToRadians(180),
|
||||
BABYLON.Tools.ToRadians(180)
|
||||
),
|
||||
],
|
||||
[
|
||||
new BABYLON.Vector3(-1.31, 2.33, -2.45),
|
||||
new BABYLON.Vector3(
|
||||
BABYLON.Tools.ToRadians(0),
|
||||
BABYLON.Tools.ToRadians(180),
|
||||
BABYLON.Tools.ToRadians(180)
|
||||
),
|
||||
],
|
||||
[
|
||||
new BABYLON.Vector3(-3.54, 5.26, -2.12),
|
||||
new BABYLON.Vector3(
|
||||
BABYLON.Tools.ToRadians(0),
|
||||
BABYLON.Tools.ToRadians(-90),
|
||||
BABYLON.Tools.ToRadians(180)
|
||||
),
|
||||
],
|
||||
];
|
||||
|
||||
//create 10 cannon clones, each with unique position/rotation data. Note that particle systems are cloned with parent meshes
|
||||
//also create 10 new animation groups with targeted animations applied to the newly cloned meshes
|
||||
for (let i = 0; i < 10; i++) {
|
||||
let cannonClone = cannon.clone("cannonClone" + i);
|
||||
cannonClone.position = cannonPositionArray[i][0];
|
||||
cannonClone.rotation = cannonPositionArray[i][1];
|
||||
let cannonAnimGroupClone = new BABYLON.AnimationGroup(
|
||||
"cannonAnimGroupClone" + i
|
||||
);
|
||||
cannonAnimGroupClone.addTargetedAnimation(
|
||||
cannonAnimGroup.targetedAnimations[0].animation,
|
||||
cannonClone.getChildMeshes()[1]
|
||||
);
|
||||
cannonAnimGroupClone.addTargetedAnimation(
|
||||
cannonAnimGroup.targetedAnimations[1].animation,
|
||||
cannonClone.getChildMeshes()[0]
|
||||
);
|
||||
|
||||
//store a key/value pair of each clone name and the name of the associated animation group name.
|
||||
cannonAnimationPairings[cannonClone.name] = cannonAnimGroupClone.name;
|
||||
//store key/value pair for the cannon name and it's readyToPlay status as 1;
|
||||
cannonReadyToPlay[cannonClone.name] = 1;
|
||||
}
|
||||
|
||||
//dispose of the original cannon, animation group, and particle system
|
||||
cannon.dispose();
|
||||
cannonAnimGroup.dispose();
|
||||
smokeBlast.dispose();
|
||||
|
||||
return scene;
|
||||
}
|
||||
119
babylonjs/webpack.config.mjs
Normal file
119
babylonjs/webpack.config.mjs
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
import path from "path";
|
||||
import TerserPlugin from "terser-webpack-plugin";
|
||||
import { LicenseFilePlugin } from "generate-license-file-webpack-plugin";
|
||||
import { fileURLToPath } from "url";
|
||||
import UnicodeEscapePlugin from "@dapplets/unicode-escape-webpack-plugin";
|
||||
import CacheBusterPlugin from "../utils/BabelCacheBuster.mjs";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
function createConfig({ es6, filename, minify }) {
|
||||
let babelPlugins = []
|
||||
let babelTargets = { chrome: "100" }
|
||||
if (!es6) {
|
||||
// enable loose class definitions for es5 (e.g. with prototype assignments)
|
||||
babelPlugins = [["@babel/plugin-transform-classes", { loose: true }],];
|
||||
// Use a reasonably ok pre-es6 classes browser.
|
||||
babelTargets = { chrome: "40" };
|
||||
}
|
||||
return {
|
||||
entry: "./src/babylon-js-benchmark.mjs",
|
||||
mode: "production",
|
||||
devtool: "source-map",
|
||||
target: ["web", es6 ? "es6" : "es5"],
|
||||
output: {
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
filename: filename,
|
||||
library: {
|
||||
name: "BabylonJSBenchmark",
|
||||
type: "globalThis",
|
||||
},
|
||||
libraryTarget: "assign",
|
||||
chunkFormat: "commonjs",
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.[cm]?js$/,
|
||||
use: {
|
||||
loader: "babel-loader",
|
||||
options: {
|
||||
presets: [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{ targets: babelTargets},
|
||||
],
|
||||
],
|
||||
plugins: [
|
||||
CacheBusterPlugin, ...babelPlugins
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new LicenseFilePlugin({
|
||||
outputFileName: "LICENSE.txt",
|
||||
}),
|
||||
new UnicodeEscapePlugin({
|
||||
test: /\.(js|jsx|ts|tsx)$/, // Escape Unicode in JavaScript and TypeScript files
|
||||
}),
|
||||
],
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
extractComments: false,
|
||||
terserOptions: {
|
||||
mangle: minify,
|
||||
format: {
|
||||
// Keep this comment for cache-busting.
|
||||
comments: /@preserve|@license|@cc_on|ThouShaltNotCache/i,
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
fallback: {
|
||||
assert: "assert/",
|
||||
fs: false,
|
||||
path: "path-browserify",
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default (env, argv) => {
|
||||
const isDevelopment = argv.mode === "development";
|
||||
|
||||
const nonMinifiedConfigs = [
|
||||
createConfig({
|
||||
es6: true,
|
||||
filename: "bundle.es6.js",
|
||||
minify: false,
|
||||
}),
|
||||
createConfig({
|
||||
es6: false,
|
||||
filename: "bundle.es5.js",
|
||||
minify: false,
|
||||
}),
|
||||
];
|
||||
|
||||
if (isDevelopment) {
|
||||
return nonMinifiedConfigs;
|
||||
}
|
||||
|
||||
return [
|
||||
createConfig({
|
||||
es6: true,
|
||||
filename: "bundle.es6.min.js",
|
||||
minify: true,
|
||||
}),
|
||||
createConfig({
|
||||
es6: false,
|
||||
filename: "bundle.es5.min.js",
|
||||
minify: true,
|
||||
}),
|
||||
];
|
||||
};
|
||||
|
|
@ -34,17 +34,20 @@ function computeIsLittleEndian() {
|
|||
}
|
||||
|
||||
const isLittleEndian = computeIsLittleEndian();
|
||||
let globalCounter = 0;
|
||||
|
||||
function randomFileContents() {
|
||||
const numBytes = (globalCounter % 128) + 2056;
|
||||
globalCounter++;
|
||||
async function *randomFileContents() {
|
||||
let counter = 1;
|
||||
while(true) {
|
||||
const numBytes = ((counter * 1192.18851371) % 2056);
|
||||
counter++;
|
||||
let result = new ArrayBuffer(numBytes);
|
||||
let view = new Uint8Array(result);
|
||||
for (let i = 0; i < numBytes; ++i)
|
||||
view[i] = (i + globalCounter) % 255;
|
||||
return new DataView(result);
|
||||
view[i] = (i + counter) % 255;
|
||||
yield new DataView(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class File {
|
||||
constructor(dataView, permissions) {
|
||||
|
|
@ -55,6 +58,8 @@ class File {
|
|||
|
||||
set data(dataView) { this._data = dataView; }
|
||||
|
||||
get byteLength() { return this._data.byteLength; }
|
||||
|
||||
swapByteOrder() {
|
||||
let hash = 0x1a2b3c4d;
|
||||
for (let i = 0; i < Math.floor(this.data.byteLength / 8) * 8; i += 8) {
|
||||
|
|
@ -144,62 +149,152 @@ class Directory {
|
|||
return count;
|
||||
}
|
||||
|
||||
async totalFileSize() {
|
||||
let size = 0;
|
||||
for await (const {entry: file} of this.forEachFileRecursively()) {
|
||||
size += file.byteLength;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
async rm(name) {
|
||||
return this.structure.delete(name);
|
||||
}
|
||||
|
||||
async visit(visitor) {
|
||||
visitor.visitDir(undefined, this);
|
||||
for await (const {name, entry, isDirectory} of this.ls()) {
|
||||
if (isDirectory)
|
||||
await entry.visit(visitor);
|
||||
else
|
||||
visitor.visitFile(name, entry);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const MAX_DIR_COUNT = 2500;
|
||||
const MAX_FILE_COUNT = 800;
|
||||
|
||||
async function setupDirectory() {
|
||||
const fs = new Directory;
|
||||
let dirs = [fs];
|
||||
let counter = 0;
|
||||
for (let dir of dirs) {
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
if (dirs.length < 400 && (counter % 3) <= 1) {
|
||||
for (let i = 0; i < 15; ++i) {
|
||||
if (dirs.length <= MAX_DIR_COUNT) {
|
||||
dirs.push(await dir.addDirectory(`dir-${i}`));
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
for (let dir of dirs) {
|
||||
for (let i = 0; i < 5; ++i) {
|
||||
if ((counter % 3) === 0) {
|
||||
await dir.addFile(`file-${i}`, new File(randomFileContents()));
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
let fileCounter = 0;
|
||||
for await (const fileContents of randomFileContents()) {
|
||||
const dirIndex = fileCounter * 107;
|
||||
const dir = dirs[dirIndex % dirs.length];
|
||||
await dir.addFile(`file-${fileCounter}`, new File(fileContents));
|
||||
fileCounter++
|
||||
if (fileCounter >= MAX_FILE_COUNT)
|
||||
break;
|
||||
}
|
||||
|
||||
return fs;
|
||||
}
|
||||
|
||||
class FSVisitor {
|
||||
visitFile(name, file) {
|
||||
}
|
||||
|
||||
visitDir(name, dir) {
|
||||
}
|
||||
}
|
||||
|
||||
class CountVisitor extends FSVisitor {
|
||||
fileCount = 0;
|
||||
dirCount = 0;
|
||||
|
||||
visitFile() {
|
||||
this.fileCount++;
|
||||
}
|
||||
|
||||
visitDir() {
|
||||
this.dirCount++;
|
||||
}
|
||||
}
|
||||
|
||||
class CountDracula extends FSVisitor {
|
||||
bytes = 0;
|
||||
visitFile(name, file) {
|
||||
this.bytes += file.byteLength;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Benchmark {
|
||||
EXPECTED_FILE_COUNT = 666;
|
||||
EXPECTED_FILE_COUNT = 739;
|
||||
|
||||
totalFileCount = 0;
|
||||
totalDirCount = 0;
|
||||
lastFileHash = undefined;
|
||||
fs;
|
||||
|
||||
async prepareForNextIteration() {
|
||||
this.fs = await setupDirectory();
|
||||
}
|
||||
|
||||
async runIteration() {
|
||||
const fs = await setupDirectory();
|
||||
|
||||
for await (let { entry: file } of fs.forEachFileRecursively()) {
|
||||
for await (let { entry: file } of this.fs.forEachFileRecursively()) {
|
||||
this.lastFileHash = file.swapByteOrder();
|
||||
}
|
||||
|
||||
for await (let { name, entry: dir } of fs.forEachDirectoryRecursively()) {
|
||||
if ((await dir.fileCount()) > 3) {
|
||||
for await (let { name } of dir.forEachFile()) {
|
||||
let result = await dir.rm(name);
|
||||
let bytesDeleted = 0;
|
||||
let counter = 0;
|
||||
for await (const { name, entry: dir } of this.fs.forEachDirectoryRecursively()) {
|
||||
const oldTotalSize = await dir.totalFileSize();
|
||||
if (await dir.fileCount() === 0)
|
||||
continue;
|
||||
counter++;
|
||||
if (counter % 13 !== 0)
|
||||
continue;
|
||||
for await (const { name } of dir.forEachFile()) {
|
||||
const result = await dir.rm(name);
|
||||
if (!result)
|
||||
throw new Error("rm should have returned true");
|
||||
}
|
||||
const totalReducedSize = oldTotalSize - dir.totalFileSize();
|
||||
bytesDeleted += totalReducedSize;
|
||||
}
|
||||
}
|
||||
if (bytesDeleted === 0)
|
||||
throw new Error("Did not delete any files");
|
||||
|
||||
for await (let _ of fs.forEachFileRecursively()) {
|
||||
this.totalFileCount++;
|
||||
const countVisitor = new CountVisitor();
|
||||
await this.fs.visit(countVisitor);
|
||||
|
||||
const countDracula = new CountDracula();
|
||||
await this.fs.visit(countDracula);
|
||||
|
||||
let fileCount = 0;
|
||||
let fileBytes = 0;
|
||||
for await (const {entry: file} of this.fs.forEachFileRecursively()) {
|
||||
fileCount++
|
||||
fileBytes += file.byteLength;
|
||||
}
|
||||
this.totalFileCount += fileCount;
|
||||
|
||||
let dirCount = 1;
|
||||
for await (let _ of this.fs.forEachDirectoryRecursively()) {
|
||||
dirCount++;
|
||||
}
|
||||
this.totalDirCount += dirCount;
|
||||
|
||||
if (countVisitor.fileCount !== fileCount)
|
||||
throw new Error(`Invalid total file count ${countVisitor.fileCount}, expected ${fileCount}.`);
|
||||
if (countDracula.bytes !== fileBytes)
|
||||
throw new Error(`Invalid total file bytes ${countDracula.bytes}, expected ${fileBytes}.`);
|
||||
if (countVisitor.dirCount !== dirCount)
|
||||
throw new Error(`Invalid total dir count ${countVisitor.dirCount}, expected ${dirCount}.`);
|
||||
|
||||
}
|
||||
|
||||
validate(iterations) {
|
||||
|
|
|
|||
|
|
@ -34,17 +34,19 @@ function computeIsLittleEndian() {
|
|||
}
|
||||
|
||||
const isLittleEndian = computeIsLittleEndian();
|
||||
let globalCounter = 0;
|
||||
|
||||
function randomFileContents() {
|
||||
const numBytes = (globalCounter % 128) + 2056;
|
||||
globalCounter++;
|
||||
function *randomFileContents() {
|
||||
let counter = 1;
|
||||
while(true) {
|
||||
const numBytes = ((counter * 1192.18851371) % 2056);
|
||||
counter++;
|
||||
let result = new ArrayBuffer(numBytes);
|
||||
let view = new Uint8Array(result);
|
||||
for (let i = 0; i < numBytes; ++i)
|
||||
view[i] = (i + globalCounter) % 255;
|
||||
return new DataView(result);
|
||||
view[i] = (i + counter) % 255;
|
||||
yield new DataView(result);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class File {
|
||||
|
|
@ -56,6 +58,8 @@ class File {
|
|||
|
||||
set data(dataView) { this._data = dataView; }
|
||||
|
||||
get byteLength() { return this._data.byteLength; }
|
||||
|
||||
swapByteOrder() {
|
||||
let hash = 0x1a2b3c4d;
|
||||
for (let i = 0; i < Math.floor(this.data.byteLength / 8) * 8; i += 8) {
|
||||
|
|
@ -141,63 +145,149 @@ class Directory {
|
|||
return count;
|
||||
}
|
||||
|
||||
totalFileSize() {
|
||||
let size = 0;
|
||||
for (const { entry:file } of this.forEachFileRecursively()) {
|
||||
size += file.byteLength;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
rm(name) {
|
||||
return this.structure.delete(name);
|
||||
}
|
||||
|
||||
visit(visitor) {
|
||||
visitor.visitDir(undefined, this);
|
||||
for (const {name, entry, isDirectory} of this.ls()) {
|
||||
if (isDirectory)
|
||||
entry.visit(visitor);
|
||||
else
|
||||
visitor.visitFile(name, entry);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const MAX_DIR_COUNT = 5000;
|
||||
const MAX_FILE_COUNT = 1200;
|
||||
|
||||
function setupDirectory() {
|
||||
const fs = new Directory;
|
||||
let dirs = [fs];
|
||||
let counter = 0;
|
||||
for (let dir of dirs) {
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
if (dirs.length < 400 && (counter % 3) <= 1) {
|
||||
dirs.push(dir.addDirectory(`dir-${i}`));
|
||||
for (let i = 0; i < 15; ++i) {
|
||||
if (dirs.length < MAX_DIR_COUNT) {
|
||||
dirs.push(dir.addDirectory(`dir-${dirs.length}`));
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
for (let dir of dirs) {
|
||||
for (let i = 0; i < 5; ++i) {
|
||||
if ((counter % 3) === 0) {
|
||||
dir.addFile(`file-${i}`, new File(randomFileContents()));
|
||||
let fileCounter = 0;
|
||||
for (const fileContents of randomFileContents()) {
|
||||
const dirIndex = fileCounter * 107;
|
||||
const dir = dirs[dirIndex % dirs.length];
|
||||
dir.addFile(`file-${fileCounter}`, new File(fileContents));
|
||||
fileCounter++
|
||||
if (fileCounter >= MAX_FILE_COUNT)
|
||||
break;
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
return fs;
|
||||
}
|
||||
|
||||
class FSVisitor {
|
||||
visitFile(name, file) {
|
||||
}
|
||||
|
||||
visitDir(name, dir) {
|
||||
}
|
||||
}
|
||||
|
||||
class CountVisitor extends FSVisitor {
|
||||
fileCount = 0;
|
||||
dirCount = 0;
|
||||
|
||||
visitFile() {
|
||||
this.fileCount++;
|
||||
}
|
||||
|
||||
visitDir() {
|
||||
this.dirCount++;
|
||||
}
|
||||
}
|
||||
|
||||
class CountDracula extends FSVisitor {
|
||||
bytes = 0;
|
||||
visitFile(name, file) {
|
||||
this.bytes += file.byteLength;
|
||||
}
|
||||
}
|
||||
|
||||
class Benchmark {
|
||||
EXPECTED_FILE_COUNT = 666;
|
||||
EXPECTED_FILE_COUNT = 1108;
|
||||
|
||||
totalFileCount = 0;
|
||||
totalDirCount = 0;
|
||||
lastFileHash = undefined;
|
||||
fs;
|
||||
|
||||
prepareForNextIteration() {
|
||||
}
|
||||
|
||||
runIteration() {
|
||||
const fs = setupDirectory();
|
||||
this.fs = setupDirectory();
|
||||
|
||||
for (let { entry: file } of fs.forEachFileRecursively()) {
|
||||
for (let { entry: file } of this.fs.forEachFileRecursively()) {
|
||||
this.lastFileHash = file.swapByteOrder();
|
||||
}
|
||||
|
||||
for (let { name, entry: dir } of fs.forEachDirectoryRecursively()) {
|
||||
if (dir.fileCount() > 3) {
|
||||
for (let { name } of dir.forEachFile()) {
|
||||
let result = dir.rm(name);
|
||||
let bytesDeleted = 0;
|
||||
let counter = 0;
|
||||
for (const { name, entry: dir } of this.fs.forEachDirectoryRecursively()) {
|
||||
const oldTotalSize = dir.totalFileSize();
|
||||
if (dir.fileCount() === 0)
|
||||
continue;
|
||||
counter++;
|
||||
if (counter % 13 !== 0)
|
||||
continue;
|
||||
for (const { name } of dir.forEachFile()) {
|
||||
const result = dir.rm(name);
|
||||
if (!result)
|
||||
throw new Error("rm should have returned true");
|
||||
}
|
||||
const totalReducedSize = oldTotalSize - dir.totalFileSize();
|
||||
bytesDeleted += totalReducedSize;
|
||||
}
|
||||
if (bytesDeleted === 0)
|
||||
throw new Error("Did not delete any files");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
const countVisitor = new CountVisitor();
|
||||
this.fs.visit(countVisitor);
|
||||
|
||||
for (let _ of fs.forEachFileRecursively()) {
|
||||
this.totalFileCount++;
|
||||
const countDracula = new CountDracula();
|
||||
this.fs.visit(countDracula);
|
||||
|
||||
let fileCount = 0;
|
||||
let fileBytes = 0;
|
||||
for (const {entry: file} of this.fs.forEachFileRecursively()) {
|
||||
fileCount++
|
||||
fileBytes += file.byteLength;
|
||||
}
|
||||
this.totalFileCount += fileCount;
|
||||
|
||||
let dirCount = 1;
|
||||
for (let _ of this.fs.forEachDirectoryRecursively()) {
|
||||
dirCount++;
|
||||
}
|
||||
this.totalDirCount += dirCount;
|
||||
|
||||
if (countVisitor.fileCount !== fileCount)
|
||||
throw new Error(`Invalid total file count ${countVisitor.fileCount}, expected ${fileCount}.`);
|
||||
if (countDracula.bytes !== fileBytes)
|
||||
throw new Error(`Invalid total file bytes ${countDracula.bytes}, expected ${fileBytes}.`);
|
||||
if (countVisitor.dirCount !== dirCount)
|
||||
throw new Error(`Invalid total dir count ${countVisitor.dirCount}, expected ${dirCount}.`);
|
||||
|
||||
}
|
||||
|
||||
validate(iterations) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
<title>JetStream 3 In-Depth Analysis</title>
|
||||
|
||||
<link rel="stylesheet" href="JetStream.css">
|
||||
<link rel="stylesheet" href="ressources/JetStream.css">
|
||||
|
||||
</head>
|
||||
<body class="overflow-scroll">
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
<title>JetStream 3</title>
|
||||
|
||||
<link rel="stylesheet" href="JetStream.css">
|
||||
<link rel="stylesheet" href="resources/JetStream.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes, viewport-fit=cover">
|
||||
|
||||
<script>
|
||||
|
|
@ -95,7 +95,7 @@
|
|||
</h1>
|
||||
|
||||
<main>
|
||||
<p class="summary">JetStream 3 is a JavaScript and WebAssembly benchmark suite focused on the most advanced web applications. It rewards browsers that start up quickly, execute code quickly, and run smoothly. For more information, read the <a href="in-depth.html">in-depth analysis</a>. Bigger scores are better.</p>
|
||||
<p class="summary">JetStream 3 is a JavaScript and WebAssembly benchmark suite focused on the most advanced web applications. It rewards browsers that start up quickly, execute code quickly, and run smoothly. For more information, read the <a href="resources/in-depth.html">in-depth analysis</a>. Bigger scores are better.</p>
|
||||
<div id="non-default-params">
|
||||
<h2>Non-standard Parameters</h2>
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ const EXPECTED_LOG_LENGTH = 6824;
|
|||
class Benchmark extends StartupBenchmark {
|
||||
lastResult;
|
||||
|
||||
constructor(iterationCount) {
|
||||
constructor({iterationCount}) {
|
||||
super({
|
||||
iterationCount,
|
||||
expectedCacheCommentCount: 464,
|
||||
|
|
|
|||
35
mobx/dist/LICENSE.txt
vendored
Normal file
35
mobx/dist/LICENSE.txt
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
This file was generated with the generate-license-file npm package!
|
||||
https://www.npmjs.com/package/generate-license-file
|
||||
|
||||
The following npm package may be included in this product:
|
||||
|
||||
- mobx@6.13.7
|
||||
|
||||
This package contains the following license:
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Michel Weststrate
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
-----------
|
||||
|
||||
This file was generated with the generate-license-file npm package!
|
||||
https://www.npmjs.com/package/generate-license-file
|
||||
|
|
@ -3,7 +3,7 @@ import { fileURLToPath } from "url";
|
|||
import TerserPlugin from "terser-webpack-plugin";
|
||||
import { LicenseFilePlugin } from "generate-license-file-webpack-plugin";
|
||||
|
||||
import CacheBusterCommentPlugin from "../startup-helper/BabelCacheBuster.mjs";
|
||||
import CacheBusterCommentPlugin from "../utils/BabelCacheBuster.mjs";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
|
|
|||
630
resources/JetStream.css
Normal file
630
resources/JetStream.css
Normal file
|
|
@ -0,0 +1,630 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2022 Apple Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
:root {
|
||||
--color-primary: #34AADC;
|
||||
--color-secondary: #86D9FF;
|
||||
--text-color-inverse: white;
|
||||
--text-color-primary: black;
|
||||
--text-color-secondary: #555555;
|
||||
--text-color-tertiary: #444444;
|
||||
--text-color-subtle: #6c6c71;
|
||||
--text-color-very-subtle: #8E8E93;
|
||||
--heading-color: #2C98D1;
|
||||
--link-hover-color: #0086BF;
|
||||
--button-color-primary: rgb(52, 170, 220);
|
||||
--error-text-color: #d24a59;
|
||||
--benchmark-heading-color: rgb(183, 183, 183);
|
||||
--benchmark-error-text-color: #ff8686;
|
||||
--benchmark-done-result-color: #4A4A4A;
|
||||
--gap: 3rem;
|
||||
--width: 200px;
|
||||
}
|
||||
|
||||
html,
|
||||
svg text {
|
||||
font-family: "Helvetica Neue", Helvetica, Verdana, sans-serif;
|
||||
font-size: 62.5%;
|
||||
font-synthesis: none;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--gap);
|
||||
margin: 0;
|
||||
font-size: 1.6rem;
|
||||
font-weight: 400;
|
||||
line-height: 1.4;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center -5vw;
|
||||
background-size: 100vw;
|
||||
padding-bottom: 0px;
|
||||
background-image: url('clouds.svg');
|
||||
overflow-y: hidden;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
table {
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
body.nonDefaultParams {
|
||||
filter: hue-rotate(152deg);
|
||||
}
|
||||
|
||||
.nonDefaultParams .summary {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#non-default-params {
|
||||
display: none;
|
||||
text-align: center;
|
||||
|
||||
& h2 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
& p {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.nonDefaultParams #non-default-params {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#non-standard-params-table {
|
||||
border-collapse: collapse;
|
||||
text-align: left;
|
||||
display: inline-block;
|
||||
margin-top: var(--gap);
|
||||
}
|
||||
|
||||
#non-standard-params-table tr {
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
#non-standard-params-table thead th {
|
||||
border-bottom: 1px solid var(--foreground);
|
||||
}
|
||||
|
||||
#non-standard-params-table tbody td {
|
||||
font-weight: normal;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#non-standard-params-table thead th,
|
||||
#non-standard-params-table tbody td {
|
||||
padding: 0.1em 0.3em;
|
||||
}
|
||||
#non-standard-params-table tbody td:nth-child(2) {
|
||||
color: var(--highlight);
|
||||
}
|
||||
|
||||
|
||||
.overflow-scroll {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.overflow-visible {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
|
||||
::selection {
|
||||
background-color: var(--color-primary);
|
||||
color: var(--text-color-inverse);
|
||||
}
|
||||
|
||||
main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--gap);
|
||||
margin: 0 auto;
|
||||
padding: 0 var(--gap);
|
||||
max-width: 1180px;
|
||||
text-align: center;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
main p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
img {
|
||||
-webkit-user-drag: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.logo {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
user-select: none;
|
||||
perspective: 600;
|
||||
}
|
||||
|
||||
.logo .logo-image {
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-image: url('JetStream3Logo.svg');
|
||||
color: transparent;
|
||||
animation: swingin 350ms ease-out forwards;
|
||||
will-change: transform, opacity;
|
||||
height: 75px;
|
||||
}
|
||||
|
||||
#jetstreams {
|
||||
background-image: url('jetstreams.svg');
|
||||
background-repeat: no-repeat;
|
||||
background-size: contain;
|
||||
background-position: center;
|
||||
padding: 2rem 0;
|
||||
margin: -2rem 0;
|
||||
}
|
||||
|
||||
#jetstreams svg {
|
||||
width: 100%;
|
||||
max-height: 120px;
|
||||
}
|
||||
|
||||
#magic {
|
||||
position: absolute;
|
||||
top: -900px;
|
||||
left: -900px;
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.summary {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.summary:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
article,
|
||||
.summary {
|
||||
max-width: 70rem;
|
||||
margin: 0 auto 0 auto;
|
||||
opacity: 0;
|
||||
animation: fadein 0.5s ease-in-out forwards;
|
||||
animation-delay: 200ms;
|
||||
}
|
||||
|
||||
article {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--gap);
|
||||
}
|
||||
h1 {
|
||||
color: var(--text-color-primary);
|
||||
text-align: center;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
color: var(--heading-color);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
text-align: left;
|
||||
color: var(--text-color-secondary);
|
||||
}
|
||||
|
||||
h5,
|
||||
h6 {
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
|
||||
h6 {
|
||||
color: var(--text-color-tertiary);
|
||||
}
|
||||
|
||||
dt {
|
||||
margin-top: 10px;
|
||||
font-weight: bold;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
dd {
|
||||
text-align: left;
|
||||
padding: 10px 20px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
a:link,
|
||||
a:visited {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
a:hover,
|
||||
a:active {
|
||||
color: var(--link-hover-color);
|
||||
}
|
||||
|
||||
#status label,
|
||||
a.button {
|
||||
display: inline-block;
|
||||
font-weight: 500;
|
||||
text-decoration: none;
|
||||
font-size: 2rem;
|
||||
background-color: var(--button-color-primary);
|
||||
background-image: linear-gradient(180deg, rgba(134, 217, 255, 1) -80%, rgb(52, 170, 220) 100%);
|
||||
color: var(--text-color-inverse);
|
||||
border: 1px solid var(--button-color-primary);
|
||||
border-radius: 2px;
|
||||
padding: 0.3rem 0.3rem 0.5rem;
|
||||
text-align: center;
|
||||
width: var(--width);
|
||||
-webkit-touch-callout: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
a.button {
|
||||
animation: fadein 500ms ease-in forwards, scaledown 500ms ease-in forwards;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
#status label,
|
||||
.button:hover {
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
#status.loading {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
margin: 48vh 0 0;
|
||||
width: 100%;
|
||||
line-height: 1.2;
|
||||
font-size: 4rem;
|
||||
font-style: italic;
|
||||
font-weight: 500;
|
||||
letter-spacing: -0.10rem;
|
||||
color: transparent;
|
||||
background-image: linear-gradient(132deg, #96E5FF 0%, #96E5FF 2%, #86D9FF 42%, #8BDAFF 84%, #96E5FF 98%, #96E5FF 100%);
|
||||
-webkit-background-clip: text;
|
||||
background-repeat: no-repeat;
|
||||
-webkit-touch-callout: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
#status.error {
|
||||
max-width: 70rem;
|
||||
margin: 0 auto 1rem;
|
||||
}
|
||||
|
||||
.error h2,
|
||||
.error p {
|
||||
color: var(--error-text-color);
|
||||
margin-bottom: 0;
|
||||
text-align: center;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.error h2 {
|
||||
font-size: 5rem;
|
||||
letter-spacing: -0.1rem;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
#result-summary:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#result-summary {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#result-summary label {
|
||||
color: var(--text-color-subtle);
|
||||
}
|
||||
|
||||
#result-summary .score {
|
||||
font-weight: bold;
|
||||
font-size: 4rem;
|
||||
line-height: 1;
|
||||
color: var(--color-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.benchmark .plot svg {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#result-summary .score .interval {
|
||||
display: block;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
#results {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-around;
|
||||
gap: var(--gap);
|
||||
margin: 0 calc(var(--gap) * -1) 0 calc(-var(--gap) * -1);
|
||||
animation: fadein 500ms ease-out forwards;
|
||||
opacity: 0;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
padding-bottom: var(--gap);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.benchmark {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
max-width: 20%;
|
||||
min-width: var(--width);
|
||||
text-align: left;
|
||||
color: var(--text-color-very-subtle);
|
||||
font-size: 1.6rem;
|
||||
scroll-margin-top: 20vh;
|
||||
scroll-margin-bottom: 20vh;
|
||||
}
|
||||
|
||||
.benchmark .result.detail {
|
||||
display: none;
|
||||
}
|
||||
.details .benchmark .result.detail {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.benchmark h4,
|
||||
.benchmark .result,
|
||||
.benchmark label,
|
||||
.benchmark .plot {
|
||||
color: transparent;
|
||||
background: linear-gradient(160deg, rgba(249, 249, 249, 1) 0%, rgba(238, 238, 238, 1) 100%);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.benchmark h3 {
|
||||
color: var(--benchmark-heading-color);
|
||||
}
|
||||
|
||||
.benchmark-running h4,
|
||||
.benchmark-running .result,
|
||||
.benchmark-running label,
|
||||
.benchmark-running .plot {
|
||||
color: var(--color-secondary);
|
||||
background-color: var(--color-secondary);
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
|
||||
.benchmark-done h3,
|
||||
.benchmark-done h4,
|
||||
.benchmark-done .result,
|
||||
.benchmark-done label,
|
||||
.benchmark-done .plot {
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
-webkit-touch-callout: revert;
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
.benchmark-error h4,
|
||||
.benchmark-error .result,
|
||||
.benchmark-error label,
|
||||
.benchmark-error .plot {
|
||||
color: var(--benchmark-error-text-color);
|
||||
background-color: var(--benchmark-error-text-color);
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
.benchmark-error h3 {
|
||||
color: var(--benchmark-error-text-color);
|
||||
}
|
||||
|
||||
.benchmark h3 {
|
||||
font-weight: 400;
|
||||
font-size: 1.6rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.benchmark-running h3 {
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.benchmark-done h3 {
|
||||
color: var(--text-color-subtle);
|
||||
}
|
||||
|
||||
.benchmark a.info {
|
||||
display: inline-block;
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
border-radius: 100%;
|
||||
background-color: var(--benchmark-heading-color);
|
||||
color: var(--text-color-inverse) !important;
|
||||
user-select: none;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
font-family: 'Times New Roman', Times, serif;
|
||||
line-height: 1.6rem;
|
||||
margin-top: -0.2rem;
|
||||
|
||||
}
|
||||
|
||||
.benchmark-running a.info {
|
||||
background-color: var(--color-primary);
|
||||
}
|
||||
|
||||
.benchmark-done a.info {
|
||||
background-color: var(--text-color-subtle);
|
||||
}
|
||||
|
||||
.benchmark h3 a,
|
||||
.benchmark h3 a:link,
|
||||
.benchmark h3 a:active,
|
||||
.benchmark h3 a:hover,
|
||||
.benchmark h3 a:visited {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.benchmark-done h3 a:hover {
|
||||
color: var(--color-primary);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.benchmark h4 {
|
||||
margin: 0.3rem 0;
|
||||
line-height: 1;
|
||||
font-weight: 400;
|
||||
font-size: 2.4rem;
|
||||
}
|
||||
|
||||
.benchmark-done h4 {
|
||||
color: var(--color-primary);
|
||||
background-color: none;
|
||||
}
|
||||
|
||||
.benchmark p,
|
||||
.benchmark-done p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.benchmark .result {
|
||||
display: inline-block;
|
||||
margin-right: 1.6rem;
|
||||
line-height: 1.3;
|
||||
font-size: 1.3rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#result-summary .benchmark {
|
||||
text-align: center;
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
margin-left: 1.6rem;
|
||||
}
|
||||
|
||||
.benchmark-done .result {
|
||||
color: var(--benchmark-done-result-color);
|
||||
}
|
||||
|
||||
.benchmark label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.benchmark-done label {
|
||||
color: var(--text-color-very-subtle);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
dt:target {
|
||||
background-color: var(--color-secondary);
|
||||
color: var(--text-color-inverse);
|
||||
padding-left: 10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.plot svg circle {
|
||||
fill: var(--color-primary);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
@keyframes fadein {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes scaledown {
|
||||
from {
|
||||
transform: scale(1.3, 1.3);
|
||||
}
|
||||
|
||||
to {
|
||||
transform: scale(1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes shine {
|
||||
0% {
|
||||
background-position: -1200px center;
|
||||
}
|
||||
|
||||
100% {
|
||||
background-position: 100vw center;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes swingin {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: rotateY(-85deg) translateZ(200px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: rotateY(0deg) translateZ(0px);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 415px) {
|
||||
body {
|
||||
background-position: center 4rem;
|
||||
}
|
||||
|
||||
.logo .logo-image {
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
#jetstreams {
|
||||
background-size: 200%;
|
||||
}
|
||||
}
|
||||
14
resources/JetStream3Logo.svg
Normal file
14
resources/JetStream3Logo.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 9.9 KiB |
15
resources/clouds.svg
Normal file
15
resources/clouds.svg
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="1582" height="400" viewBox="0 0 1582 400" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Copyright © 2019 Apple Inc. All rights reserved. -->
|
||||
<defs>
|
||||
<path id="b" d="M1581.5351,399.898438 L1581.5351,358.005601 C1581.5351,312.268183 1541.19277,275.1917 1491.43042,275.1917 C1450.64807,275.1917 1416.21078,300.099758 1405.10264,334.260413 C1400.43887,333.385508 1395.61073,332.926025 1390.66617,332.926025 C1388.37195,332.926025 1386.10341,333.036175 1383.86398,333.229724 C1376.13724,267.399376 1315.50132,216.14187 1241.82258,216.14187 C1199.31271,216.14187 1161.16187,233.219838 1134.9872,260.299423 C1113.40269,263.202662 1094.87257,274.711761 1083.62404,290.913249 C1073.08089,286.962012 1061.57383,284.746424 1049.51034,284.658304 C1044.8089,230.165536 995.241732,187.282576 934.742775,187.282576 C879.5873,187.282576 833.514544,222.927109 822.238618,270.513473 C806.788579,260.746317 788.255038,254.823396 768.250798,254.201835 C768.855171,251.032663 769.18732,247.780091 769.18732,244.451989 C769.18732,213.446343 741.83986,188.311692 708.104535,188.311692 C696.749852,188.311692 686.126238,191.167723 677.017838,196.127619 C663.949337,174.58071 638.921781,160 610.177243,160 C568.537128,160 534.69394,190.587075 533.736873,228.645467 C507.409829,230.16711 484.936733,244.705333 473.845714,265.347439 C452.004386,227.565997 408.768588,201.827094 358.973715,201.827094 C322.127494,201.827094 288.886968,215.937306 265.229096,238.56998 C261.739825,237.690353 258.069071,237.211988 254.276757,237.211988 C236.873206,237.211988 221.99501,247.101882 215.903339,261.097224 C210.077045,258.211294 203.411818,256.571633 196.328838,256.571633 C173.761577,256.571633 155.431776,273.199559 155.024295,293.851107 C140.462839,286.979322 123.970128,283.078439 106.475835,283.078439 C47.6701506,283.078439 4.8316906e-13,326.89138 4.8316906e-13,380.938827 L0,399.898438"/>
|
||||
<filter id="a" width="120.5%" height="235.5%" x="-10.3%" y="-78.2%" filterUnits="objectBoundingBox">
|
||||
<feOffset dy="-25" in="SourceAlpha" result="shadowOffsetOuter1"/>
|
||||
<feGaussianBlur stdDeviation="50" in="shadowOffsetOuter1" result="shadowBlurOuter1"/>
|
||||
<feColorMatrix values="0 0 0 0 0.807429766 0 0 0 0 0.94268743 0 0 0 0 1 0 0 0 1 0" in="shadowBlurOuter1"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<use fill="black" filter="url(#a)" xlink:href="#b"/>
|
||||
<use fill="white" xlink:href="#b"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
46
resources/jetstreams.svg
Normal file
46
resources/jetstreams.svg
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="2647" height="120" viewBox="0 0 2647 120">
|
||||
<!-- Copyright © 2019 Apple Inc. All rights reserved. -->
|
||||
<style>
|
||||
.line {
|
||||
mix-blend-mode: multiply;
|
||||
stroke-dasharray: 2680;
|
||||
stroke-dashoffset: 2680;
|
||||
animation: dash 1.1s ease-in forwards;
|
||||
animation-delay: 400ms;
|
||||
}
|
||||
|
||||
.line.second {
|
||||
animation-delay: 500ms;
|
||||
animation-duration: 900ms;
|
||||
}
|
||||
|
||||
.line.third {
|
||||
animation-delay: 600ms;
|
||||
animation-duration: 800ms;
|
||||
}
|
||||
|
||||
.line.fourth {
|
||||
animation-delay: 700ms;
|
||||
animation-duration: 700ms;
|
||||
}
|
||||
|
||||
.line.fifth {
|
||||
animation-delay: 800ms;
|
||||
animation-duration: 600ms;
|
||||
}
|
||||
|
||||
@keyframes dash {
|
||||
to {
|
||||
stroke-dashoffset: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<g fill="none" fill-rule="evenodd" opacity=".8" stroke-dasharray="2680" stroke-linecap="square" stroke="#B9EAFF" stroke-width="5">
|
||||
<path class="line" d="M0.381287582,77.2851563 C45.5977594,100.205019 115.707877,111.66495 210.71164,111.66495 C353.217284,111.66495 433.15655,50.4282334 626.183452,50.4282334 C819.210355,50.4282334 1003.20257,83.2313059 1085.21867,84.6042334 C1167.23478,85.977161 1231.04683,71 1322.53193,71 C1414.01704,71 1405.89836,77.9769045 1469.70623,77.9769045 C1533.51411,77.9769045 1858.0854,41.1147334 1982.42221,41.1152334 C2106.759,41.1157334 2336.34112,96.9169334 2457.44102,96.9169334 C2538.17429,96.9169334 2612.48771,90.6035905 2680.38129,77.9769045"/>
|
||||
<path class="line second" d="M0.381287582,77.2851563 C52.8221181,59.380541 115.923899,50.4282334 189.68663,50.4282334 C300.330726,50.4282334 463.775156,77.2851563 587.977497,77.2851563 C712.179836,77.2851563 841.854221,41.1162334 960.608924,41.1157334 C1079.36363,41.1152334 1175.54909,71 1267.0342,71 C1358.5193,71 1486.92586,84.8073502 1579.31596,84.8073502 C1671.70606,84.8073502 1951.64553,37.773825 2091.51218,38.3793587 C2231.37883,38.9848924 2309.70347,76.3864611 2465.75572,78.8007813 C2569.79056,80.410328 2641.3324,76.8419454 2680.38129,68.0956334"/>
|
||||
<path class="line third" d="M0.381287582,68.0956334 C46.104713,82.5628758 116.468307,89.796497 211.472071,89.796497 C353.977713,89.796497 569.766201,41.1157334 695.40436,41.1157334 C821.042519,41.1157334 1029.874,71.5221545 1121.3591,71.5221545 C1212.84421,71.5221545 1231.04683,71 1322.53193,71 C1414.01704,71 1470.55153,86.8321594 1614.81651,89.796497 C1759.08149,92.7608346 1917.33862,49.8226997 2057.20527,50.4282334 C2197.07192,51.0337671 2372.16992,114.838073 2475.15354,114.838073 C2543.8093,114.838073 2612.21853,107.48016 2680.38129,92.7643334"/>
|
||||
<path class="line fourth" d="M0.381287582,50.4282334 C39.5600335,20.8094111 105.603499,5.66666667 198.511683,5 C337.873959,4 411.779393,89.7993958 588.034245,89.7993958 C764.289095,89.7993958 886.574266,57.2387752 996.542944,57.2387752 C1106.51162,57.2387752 1231.16568,71 1322.65962,71 C1414.15356,71 1447.8544,56.1829752 1541.98759,57.2387752 C1636.12078,58.2945752 1817.26413,89.8073502 1971.66487,89.8073502 C2126.06561,89.8073502 2305.87367,16.3803334 2455.48134,17.3806334 C2555.2198,18.0475001 2629.51978,33.3807334 2678.38129,63.3803334"/>
|
||||
<path class="line fifth" d="M0.381287582,50.4282334 C100.711815,28.2065001 198.37896,17.0956334 293.382723,17.0956334 C435.888367,17.0956334 531.07636,67.2833421 716.990501,71.5221545 C902.904641,75.7609669 1020.95162,46.3806334 1100.3489,46.3806334 C1179.74619,46.3806334 1250.52195,71 1342.00705,71 C1433.49216,71 1503.60201,41.3248334 1597.7261,42.3806334 C1691.8502,43.4364334 1891.84425,89.1938621 2031.7109,89.7993958 C2171.57755,90.4049295 2341.72526,52.2362334 2469.03608,52.2362334 C2553.90996,52.2362334 2624.35836,59.7595397 2680.38129,74.8061523"/>
|
||||
<path class="line third" d="M0.381287582,63.3803334 C29.9004627,42.0463503 86.1138292,31.3793587 169.021387,31.3793587 C293.382723,31.3793587 530.433313,103.701906 703.857385,103.731049 C877.281458,103.760193 1001.04857,58.6844334 1102.10823,59.8364334 C1203.1679,60.9884334 1231.04683,71 1322.53193,71 C1414.01704,71 1625.37248,44.1157334 1733.57121,44.1157334 C1841.76995,44.1157334 1984.50341,75.8774804 2102.06815,76.3864611 C2219.6329,76.8954417 2348.05336,31.3793587 2475.36419,31.3793587 C2531.94676,31.3793587 2600.2858,43.232817 2680.38129,66.9397334"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.4 KiB |
|
|
@ -81,7 +81,7 @@ export async function logGroup(name, body) {
|
|||
}
|
||||
|
||||
|
||||
export function printHelp(message = "", optionDefinitions) {
|
||||
export function printHelp(message, optionDefinitions) {
|
||||
const usage = commandLineUsage([
|
||||
{
|
||||
header: "Run all tests",
|
||||
|
|
@ -91,13 +91,13 @@ export function printHelp(message = "", optionDefinitions) {
|
|||
optionList: optionDefinitions,
|
||||
},
|
||||
]);
|
||||
if (!message) {
|
||||
if (!message?.length) {
|
||||
console.log(usage);
|
||||
process.exit(0);
|
||||
} else {
|
||||
console.error(message);
|
||||
console.error();
|
||||
console.error(usage);
|
||||
console.log();
|
||||
console.log(usage);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
import serve from "./server.mjs";
|
||||
import { Builder, Capabilities, logging } from "selenium-webdriver";
|
||||
import { Options as ChromeOptions } from "selenium-webdriver/chrome.js";
|
||||
import { Options as FirefoxOptions } from "selenium-webdriver/firefox.js";
|
||||
import commandLineArgs from "command-line-args";
|
||||
import { promises as fs } from "fs";
|
||||
import path from "path";
|
||||
|
|
@ -33,6 +35,45 @@ import os from "os";
|
|||
|
||||
import {logInfo, logError, printHelp, runTest} from "./helper.mjs";
|
||||
|
||||
const TESTS = [
|
||||
{
|
||||
name: "Run Single Suite",
|
||||
tags: ["all", "main"],
|
||||
run() {
|
||||
return runEnd2EndTest("Run Single Suite", { test: "proxy-mobx" });
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Run Multiple Suites",
|
||||
tags: ["all", "main"],
|
||||
run() {
|
||||
return runEnd2EndTest("Run Multiple Suites", { test: "prismjs-startup-es6,postcss-wtb" });
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Run Tag No Prefetch",
|
||||
tags: ["all", "main"],
|
||||
run() {
|
||||
return runEnd2EndTest("Run Tag No Prefetch", { tag: "proxy", prefetchResources: "false" });
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Run Disabled Suite",
|
||||
tags: ["all", "disabled"],
|
||||
run() {
|
||||
return runEnd2EndTest("Run Disabled Suite", { tag: "disabled" });
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Run Default Suite",
|
||||
tags: ["all", "default"],
|
||||
run() {
|
||||
return runEnd2EndTest("Run Default Suite");
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
const VALID_TAGS = Array.from(new Set(TESTS.map((each) => each.tags).flat()));
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
|
|
@ -42,18 +83,24 @@ const optionDefinitions = [
|
|||
{ name: "browser", type: String, description: "Set the browser to test, choices are [safari, firefox, chrome, edge]. By default the $BROWSER env variable is used." },
|
||||
{ name: "port", type: Number, defaultValue: 8010, description: "Set the test-server port, The default value is 8010." },
|
||||
{ name: "help", alias: "h", description: "Print this help text." },
|
||||
{ name: "suite", type: String, defaultOption: true, typeLabel: `{underline choices}: ${VALID_TAGS.join(", ")}`, description: "Run a specific suite by name." }
|
||||
];
|
||||
|
||||
const options = commandLineArgs(optionDefinitions);
|
||||
|
||||
if ("help" in options)
|
||||
printHelp(optionDefinitions);
|
||||
printHelp("". optionDefinitions);
|
||||
|
||||
if (options.suite && !VALID_TAGS.includes(options.suite))
|
||||
printHelp(`Invalid suite: ${options.suite}. Choices are: ${VALID_TAGS.join(", ")}`);
|
||||
|
||||
const BROWSER = options?.browser;
|
||||
if (!BROWSER)
|
||||
printHelp("No browser specified, use $BROWSER or --browser", optionDefinitions);
|
||||
const IS_HEADLESS = os.platform() === "linux" && !process.env.DISPLAY;
|
||||
|
||||
let capabilities;
|
||||
let browserOptions;
|
||||
switch (BROWSER) {
|
||||
case "safari":
|
||||
capabilities = Capabilities.safari();
|
||||
|
|
@ -61,11 +108,19 @@ switch (BROWSER) {
|
|||
break;
|
||||
|
||||
case "firefox": {
|
||||
capabilities = Capabilities.firefox();
|
||||
capabilities = Capabilities.firefox()
|
||||
if (IS_HEADLESS) {
|
||||
browserOptions = new FirefoxOptions();
|
||||
browserOptions.addArguments("-headless");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "chrome": {
|
||||
capabilities = Capabilities.chrome();
|
||||
capabilities = Capabilities.chrome()
|
||||
if (IS_HEADLESS) {
|
||||
browserOptions = new ChromeOptions();
|
||||
browserOptions.addArguments("--headless");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "edge": {
|
||||
|
|
@ -73,7 +128,7 @@ switch (BROWSER) {
|
|||
break;
|
||||
}
|
||||
default: {
|
||||
printHelp(`Invalid browser "${BROWSER}", choices are: "safari", "firefox", "chrome", "edge"`);
|
||||
printHelp(`Invalid browser "${BROWSER}", choices are: "safari", "firefox", "chrome", "edge"`, optionDefinitions);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,12 +146,19 @@ const server = await serve(PORT);
|
|||
|
||||
async function runTests() {
|
||||
let success = true;
|
||||
const suiteFilter = options.suite || "all";
|
||||
|
||||
const testsToRun = TESTS.filter(test => test.tags.includes(suiteFilter));
|
||||
|
||||
if (testsToRun.length === 0) {
|
||||
console.error(`No suite found for filter: ${suiteFilter}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
success &&= await runEnd2EndTest("Run Single Suite", { test: "proxy-mobx" });
|
||||
success &&= await runEnd2EndTest("Run Multiple Suites", { test: "prismjs-startup-es6,postcss-wtb" });
|
||||
success &&= await runEnd2EndTest("Run Tag No Prefetch", { tag: "proxy", prefetchResources: "false" });
|
||||
success &&= await runEnd2EndTest("Run Disabled Suite", { tag: "disabled" });
|
||||
success &&= await runEnd2EndTest("Run Default Suite");
|
||||
for (const test of testsToRun) {
|
||||
success &&= await test.run();
|
||||
}
|
||||
} finally {
|
||||
server.close();
|
||||
}
|
||||
|
|
@ -109,7 +171,20 @@ async function runEnd2EndTest(name, params) {
|
|||
}
|
||||
|
||||
async function testEnd2End(params) {
|
||||
const driver = await new Builder().withCapabilities(capabilities).build();
|
||||
const builder = new Builder().withCapabilities(capabilities);
|
||||
if (browserOptions) {
|
||||
switch(BROWSER) {
|
||||
case "firefox":
|
||||
builder.setFirefoxOptions(browserOptions);
|
||||
break;
|
||||
case "chrome":
|
||||
builder.setChromeOptions(browserOptions);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
const driver = await builder.build();
|
||||
const sessionId = (await driver.getSession()).getId();
|
||||
const driverCapabilities = await driver.getCapabilities();
|
||||
logInfo(`Browser: ${driverCapabilities.getBrowserName()} ${driverCapabilities.getBrowserVersion()}`);
|
||||
|
|
|
|||
|
|
@ -43,11 +43,16 @@ async function findPackageJsonFiles(dir, accumulator=[]) {
|
|||
if (dirent.name === "node_modules" || dirent.name === ".git")
|
||||
continue;
|
||||
const fullPath = path.join(dir, dirent.name);
|
||||
if (dirent.isDirectory())
|
||||
if (dirent.isDirectory()) {
|
||||
// Ignore third-party git dirs.
|
||||
if (fs.existsSync(path.join(fullPath, ".git"))) {
|
||||
continue;
|
||||
}
|
||||
findPackageJsonFiles(fullPath, accumulator);
|
||||
else if (dirent.name === "package.json")
|
||||
} else if (dirent.name === "package.json") {
|
||||
accumulator.push(fullPath)
|
||||
}
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
|
|
@ -56,6 +61,7 @@ async function runBuilds() {
|
|||
let success = true;
|
||||
|
||||
logInfo(`Found ${packageJsonFiles.length} package.json files`);
|
||||
console.log(packageJsonFiles)
|
||||
let filteredPackageJsonFiles = packageJsonFiles;
|
||||
if (options.changedDirs?.size === 0) {
|
||||
logInfo("No file changes detected, skipping all");
|
||||
|
|
|
|||
|
|
@ -31,19 +31,97 @@ import { fileURLToPath } from "url";
|
|||
|
||||
import { logGroup, logInfo, printHelp, runTest, sh } from "./helper.mjs";
|
||||
|
||||
const FILE_PATH = fileURLToPath(import.meta.url);
|
||||
const SRC_DIR = path.dirname(path.dirname(FILE_PATH));
|
||||
const CLI_PATH = path.join(SRC_DIR, "cli.js");
|
||||
const UNIT_TEST_PATH = path.join(SRC_DIR, "tests", "unit-tests.js");
|
||||
|
||||
const TESTS = [
|
||||
{
|
||||
name: "UnitTests",
|
||||
tags: ["all", "main", "unit"],
|
||||
run(shell_binary) {
|
||||
return runTest("UnitTests", () => sh(shell_binary, UNIT_TEST_PATH));
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Single Suite",
|
||||
tags: ["all", "main", "single"],
|
||||
run(shell_binary) {
|
||||
return runCLITest("Single Suite", shell_binary, "proxy-mobx");
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Tag No Prefetch",
|
||||
tags: ["all", "main", "no-prefetch"],
|
||||
run(shell_binary) {
|
||||
return runCLITest(
|
||||
"Tag No Prefetch",
|
||||
shell_binary,
|
||||
"proxy",
|
||||
"argon2-wasm",
|
||||
"--no-prefetch"
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Grouped with Details",
|
||||
tags: ["all", "main", "group-details"],
|
||||
run(shell_binary) {
|
||||
return runCLITest("Grouped with Details", shell_binary, "SunSpider", "--group-details");
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Disabled Suite",
|
||||
tags: ["all", "disabled"],
|
||||
run(shell_binary) {
|
||||
return runCLITest("Disabled Suite", shell_binary, "disabled");
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Default Suite",
|
||||
tags: ["all", "default"],
|
||||
run(shell_binary) {
|
||||
return runCLITest("Default Suite", shell_binary);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const VALID_TAGS = Array.from(new Set(TESTS.map((each) => each.tags).flat()));
|
||||
|
||||
const optionDefinitions = [
|
||||
{ name: "shell", type: String, description: "Set the shell to test, choices are [jsc, v8, spidermonkey]." },
|
||||
{
|
||||
name: "shell",
|
||||
type: String,
|
||||
description: "Set the shell to test, choices are [jsc, v8, spidermonkey].",
|
||||
},
|
||||
{ name: "help", alias: "h", description: "Print this help text." },
|
||||
{
|
||||
name: "suite",
|
||||
type: String,
|
||||
defaultOption: true,
|
||||
typeLabel: `choices: ${VALID_TAGS.join(", ")}`,
|
||||
description: "Run a specific suite by name.",
|
||||
},
|
||||
];
|
||||
|
||||
const options = commandLineArgs(optionDefinitions);
|
||||
|
||||
if ("help" in options)
|
||||
printHelp(optionDefinitions);
|
||||
if ("help" in options) {
|
||||
printHelp("", optionDefinitions);
|
||||
}
|
||||
|
||||
if (options.suite && !VALID_TAGS.includes(options.suite)) {
|
||||
printHelp(
|
||||
`Invalid suite: ${options.suite}. Choices are: ${VALID_TAGS.join(", ")}`,
|
||||
optionDefinitions
|
||||
);
|
||||
}
|
||||
|
||||
const JS_SHELL = options?.shell;
|
||||
if (!JS_SHELL)
|
||||
if (!JS_SHELL) {
|
||||
printHelp("No javascript shell specified, use --shell", optionDefinitions);
|
||||
}
|
||||
|
||||
const SHELL_NAME = (function () {
|
||||
switch (JS_SHELL) {
|
||||
|
|
@ -58,64 +136,74 @@ const SHELL_NAME = (function() {
|
|||
return "v8";
|
||||
}
|
||||
default: {
|
||||
printHelp(`Invalid shell "${JS_SHELL}", choices are: "jsc", "spidermonkey" and "v8)`);
|
||||
printHelp(
|
||||
`Invalid shell "${JS_SHELL}", choices are: "jsc", "spidermonkey" and "v8)`,
|
||||
optionDefinitions
|
||||
);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
const FILE_PATH = fileURLToPath(import.meta.url);
|
||||
const SRC_DIR = path.dirname(path.dirname(FILE_PATH));
|
||||
const CLI_PATH = path.join(SRC_DIR, "cli.js");
|
||||
const UNIT_TEST_PATH = path.join(SRC_DIR, "tests", "unit-tests.js");
|
||||
|
||||
function convertCliArgs(cli, ...cliArgs) {
|
||||
if (SHELL_NAME == "spidermonkey")
|
||||
return [cli, ...cliArgs];
|
||||
if (SHELL_NAME == "spidermonkey") return [cli, ...cliArgs];
|
||||
return [cli, "--", ...cliArgs];
|
||||
}
|
||||
|
||||
|
||||
async function runTests() {
|
||||
const shellBinary = await logGroup(`Installing JavaScript Shell: ${SHELL_NAME}`, testSetup);
|
||||
const shell_binary = await logGroup(`Installing JavaScript Shell: ${SHELL_NAME}`, testSetup);
|
||||
const suiteFilter = options.suite || "all";
|
||||
let success = true;
|
||||
success &&= await runTest("Run UnitTests", () => sh(shellBinary, UNIT_TEST_PATH));
|
||||
success &&= await runCLITest("Run Single Suite", shellBinary, "proxy-mobx");
|
||||
success &&= await runCLITest("Run Tag No Prefetch", shellBinary, "proxy", "argon2-wasm", "--no-prefetch");
|
||||
success &&= await runCLITest("Run Grouped with Details", shellBinary, "SunSpider", "--group-details");
|
||||
success &&= await runCLITest("Run Disabled Suite", shellBinary, "disabled");
|
||||
success &&= await runCLITest("Run Default Suite", shellBinary);
|
||||
if (!success)
|
||||
const testsToRun = TESTS.filter((test) => test.tags.includes(suiteFilter));
|
||||
|
||||
if (testsToRun.length === 0) {
|
||||
console.error(`No suite found for filter: ${suiteFilter}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
for (const test of testsToRun) {
|
||||
success &&= await test.run(shell_binary);
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
function jsvuOSName() {
|
||||
const osName = () => {
|
||||
switch (os.platform()) {
|
||||
case "win32": return "win";
|
||||
case "darwin": return "mac";
|
||||
case "linux": return "linux";
|
||||
default: throw new Error("Unsupported OS");
|
||||
case "win32":
|
||||
return "win";
|
||||
case "darwin":
|
||||
return "mac";
|
||||
case "linux":
|
||||
return "linux";
|
||||
default:
|
||||
throw new Error("Unsupported OS");
|
||||
}
|
||||
};
|
||||
const osArch = () => {
|
||||
switch (os.arch()) {
|
||||
case "x64": return "64";
|
||||
case "arm64": return "64arm";
|
||||
default: throw new Error("Unsupported architecture");
|
||||
case "x64":
|
||||
return "64";
|
||||
case "arm64":
|
||||
return "64arm";
|
||||
default:
|
||||
throw new Error("Unsupported architecture");
|
||||
}
|
||||
};
|
||||
return `${osName()}${osArch()}`;
|
||||
}
|
||||
|
||||
const DEFAULT_JSC_LOCATION = "/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Helpers/jsc"
|
||||
const DEFAULT_JSC_LOCATION =
|
||||
"/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Helpers/jsc";
|
||||
|
||||
async function testSetup() {
|
||||
await sh("jsvu", `--engines=${SHELL_NAME}`, `--os=${jsvuOSName()}`);
|
||||
let shellBinary = path.join(os.homedir(), ".jsvu/bin", SHELL_NAME);
|
||||
if (!fs.existsSync(shellBinary) && SHELL_NAME == "javascriptcore")
|
||||
shellBinary = DEFAULT_JSC_LOCATION;
|
||||
if (!fs.existsSync(shellBinary))
|
||||
throw new Error(`Could not find shell binary: ${shellBinary}`);
|
||||
if (!fs.existsSync(shellBinary)) throw new Error(`Could not find shell binary: ${shellBinary}`);
|
||||
logInfo(`Installed JavaScript Shell: ${shellBinary}`);
|
||||
return shellBinary;
|
||||
}
|
||||
|
|
@ -126,8 +214,10 @@ function runCLITest(name, shellBinary, ...args) {
|
|||
|
||||
async function runShell(shellBinary, ...args) {
|
||||
const result = await sh(shellBinary, ...args);
|
||||
if (result.stdoutString.includes("JetStream3 failed"))
|
||||
throw new Error("test failed")
|
||||
// JSC does not set a non-0 exit status on async exceptions.
|
||||
if (SHELL_NAME == "javascriptcore" && result.stdoutString.includes("JetStream3 failed")) {
|
||||
throw new Error("test failed");
|
||||
}
|
||||
}
|
||||
|
||||
setImmediate(runTests);
|
||||
|
|
|
|||
3
utils/polyfills/README
Normal file
3
utils/polyfills/README
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Polyfills shared across different workloads, for browser APIs that are not available in JavaScript engine shells, e.g., `TextDecoder`.
|
||||
To make performance between browser and shell measurements not too dissimilar, these shouldn't account for a major part of the runtime (e.g., ideally only be used during initialization, outside of the main measurement loop).
|
||||
Also, please also add a link to the original sources and licensing information in each subdirectory.
|
||||
286
utils/polyfills/fast-text-encoding/1.0.3/text.js
Normal file
286
utils/polyfills/fast-text-encoding/1.0.3/text.js
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
/*
|
||||
* Copyright 2017 Sam Thorogood. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Polyfill for TextEncoder and TextDecoder.
|
||||
*
|
||||
* You probably want `text.min.js`, and not this file directly.
|
||||
*/
|
||||
|
||||
//JSC
|
||||
const global = (0,eval)("this");
|
||||
|
||||
(function(scope) {
|
||||
'use strict';
|
||||
|
||||
// fail early
|
||||
if (scope['TextEncoder'] && scope['TextDecoder']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// used for FastTextDecoder
|
||||
const validUtfLabels = ['utf-8', 'utf8', 'unicode-1-1-utf-8'];
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FastTextEncoder() {
|
||||
// This does not accept an encoding, and always uses UTF-8:
|
||||
// https://www.w3.org/TR/encoding/#dom-textencoder
|
||||
}
|
||||
|
||||
Object.defineProperty(FastTextEncoder.prototype, 'encoding', {value: 'utf-8'});
|
||||
|
||||
/**
|
||||
* @param {string} string
|
||||
* @param {{stream: boolean}=} options
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
FastTextEncoder.prototype['encode'] = function(string, options={stream: false}) {
|
||||
if (options.stream) {
|
||||
throw new Error(`Failed to encode: the 'stream' option is unsupported.`);
|
||||
}
|
||||
|
||||
let pos = 0;
|
||||
const len = string.length;
|
||||
|
||||
let at = 0; // output position
|
||||
let tlen = Math.max(32, len + (len >>> 1) + 7); // 1.5x size
|
||||
let target = new Uint8Array((tlen >>> 3) << 3); // ... but at 8 byte offset
|
||||
|
||||
while (pos < len) {
|
||||
let value = string.charCodeAt(pos++);
|
||||
if (value >= 0xd800 && value <= 0xdbff) {
|
||||
// high surrogate
|
||||
if (pos < len) {
|
||||
const extra = string.charCodeAt(pos);
|
||||
if ((extra & 0xfc00) === 0xdc00) {
|
||||
++pos;
|
||||
value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
|
||||
}
|
||||
}
|
||||
if (value >= 0xd800 && value <= 0xdbff) {
|
||||
continue; // drop lone surrogate
|
||||
}
|
||||
}
|
||||
|
||||
// expand the buffer if we couldn't write 4 bytes
|
||||
if (at + 4 > target.length) {
|
||||
tlen += 8; // minimum extra
|
||||
tlen *= (1.0 + (pos / string.length) * 2); // take 2x the remaining
|
||||
tlen = (tlen >>> 3) << 3; // 8 byte offset
|
||||
|
||||
const update = new Uint8Array(tlen);
|
||||
update.set(target);
|
||||
target = update;
|
||||
}
|
||||
|
||||
if ((value & 0xffffff80) === 0) { // 1-byte
|
||||
target[at++] = value; // ASCII
|
||||
continue;
|
||||
} else if ((value & 0xfffff800) === 0) { // 2-byte
|
||||
target[at++] = ((value >>> 6) & 0x1f) | 0xc0;
|
||||
} else if ((value & 0xffff0000) === 0) { // 3-byte
|
||||
target[at++] = ((value >>> 12) & 0x0f) | 0xe0;
|
||||
target[at++] = ((value >>> 6) & 0x3f) | 0x80;
|
||||
} else if ((value & 0xffe00000) === 0) { // 4-byte
|
||||
target[at++] = ((value >>> 18) & 0x07) | 0xf0;
|
||||
target[at++] = ((value >>> 12) & 0x3f) | 0x80;
|
||||
target[at++] = ((value >>> 6) & 0x3f) | 0x80;
|
||||
} else {
|
||||
continue; // out of range
|
||||
}
|
||||
|
||||
target[at++] = (value & 0x3f) | 0x80;
|
||||
}
|
||||
|
||||
// Use subarray if slice isn't supported (IE11). This will use more memory
|
||||
// because the original array still exists.
|
||||
return target.slice ? target.slice(0, at) : target.subarray(0, at);
|
||||
}
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {string=} utfLabel
|
||||
* @param {{fatal: boolean}=} options
|
||||
*/
|
||||
function FastTextDecoder(utfLabel='utf-8', options={fatal: false}) {
|
||||
if (validUtfLabels.indexOf(utfLabel.toLowerCase()) === -1) {
|
||||
throw new RangeError(
|
||||
`Failed to construct 'TextDecoder': The encoding label provided ('${utfLabel}') is invalid.`);
|
||||
}
|
||||
// if (options.fatal) {
|
||||
// throw new Error(`Failed to construct 'TextDecoder': the 'fatal' option is unsupported.`);
|
||||
// }
|
||||
}
|
||||
|
||||
Object.defineProperty(FastTextDecoder.prototype, 'encoding', {value: 'utf-8'});
|
||||
|
||||
Object.defineProperty(FastTextDecoder.prototype, 'fatal', {value: false});
|
||||
|
||||
Object.defineProperty(FastTextDecoder.prototype, 'ignoreBOM', {value: false});
|
||||
|
||||
/**
|
||||
* @param {!Uint8Array} bytes
|
||||
* @return {string}
|
||||
*/
|
||||
function decodeBuffer(bytes) {
|
||||
return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString('utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!Uint8Array} bytes
|
||||
* @return {string}
|
||||
*/
|
||||
function decodeSyncXHR(bytes) {
|
||||
const b = new Blob([bytes], {type: 'text/plain;charset=UTF-8'});
|
||||
const u = URL.createObjectURL(b);
|
||||
|
||||
// This hack will fail in non-Edgium Edge because sync XHRs are disabled (and
|
||||
// possibly in other places), so ensure there's a fallback call.
|
||||
try {
|
||||
const x = new XMLHttpRequest();
|
||||
x.open('GET', u, false);
|
||||
x.send();
|
||||
return x.responseText;
|
||||
} catch (e) {
|
||||
return decodeFallback(bytes);
|
||||
} finally {
|
||||
URL.revokeObjectURL(u);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!Uint8Array} bytes
|
||||
* @return {string}
|
||||
*/
|
||||
function decodeFallback(bytes) {
|
||||
let inputIndex = 0;
|
||||
|
||||
// Create a working buffer for UTF-16 code points, but don't generate one
|
||||
// which is too large for small input sizes. UTF-8 to UCS-16 conversion is
|
||||
// going to be at most 1:1, if all code points are ASCII. The other extreme
|
||||
// is 4-byte UTF-8, which results in two UCS-16 points, but this is still 50%
|
||||
// fewer entries in the output.
|
||||
const pendingSize = Math.min(256 * 256, bytes.length + 1);
|
||||
const pending = new Uint16Array(pendingSize);
|
||||
const chunks = [];
|
||||
let pendingIndex = 0;
|
||||
|
||||
for (;;) {
|
||||
const more = inputIndex < bytes.length;
|
||||
|
||||
// If there's no more data or there'd be no room for two UTF-16 values,
|
||||
// create a chunk. This isn't done at the end by simply slicing the data
|
||||
// into equal sized chunks as we might hit a surrogate pair.
|
||||
if (!more || (pendingIndex >= pendingSize - 1)) {
|
||||
// nb. .apply and friends are *really slow*. Low-hanging fruit is to
|
||||
// expand this to literally pass pending[0], pending[1], ... etc, but
|
||||
// the output code expands pretty fast in this case.
|
||||
chunks.push(String.fromCharCode.apply(null, pending.subarray(0, pendingIndex)));
|
||||
|
||||
if (!more) {
|
||||
return chunks.join('');
|
||||
}
|
||||
|
||||
// Move the buffer forward and create another chunk.
|
||||
bytes = bytes.subarray(inputIndex);
|
||||
inputIndex = 0;
|
||||
pendingIndex = 0;
|
||||
}
|
||||
|
||||
// The native TextDecoder will generate "REPLACEMENT CHARACTER" where the
|
||||
// input data is invalid. Here, we blindly parse the data even if it's
|
||||
// wrong: e.g., if a 3-byte sequence doesn't have two valid continuations.
|
||||
|
||||
const byte1 = bytes[inputIndex++];
|
||||
if ((byte1 & 0x80) === 0) { // 1-byte or null
|
||||
pending[pendingIndex++] = byte1;
|
||||
} else if ((byte1 & 0xe0) === 0xc0) { // 2-byte
|
||||
const byte2 = bytes[inputIndex++] & 0x3f;
|
||||
pending[pendingIndex++] = ((byte1 & 0x1f) << 6) | byte2;
|
||||
} else if ((byte1 & 0xf0) === 0xe0) { // 3-byte
|
||||
const byte2 = bytes[inputIndex++] & 0x3f;
|
||||
const byte3 = bytes[inputIndex++] & 0x3f;
|
||||
pending[pendingIndex++] = ((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3;
|
||||
} else if ((byte1 & 0xf8) === 0xf0) { // 4-byte
|
||||
const byte2 = bytes[inputIndex++] & 0x3f;
|
||||
const byte3 = bytes[inputIndex++] & 0x3f;
|
||||
const byte4 = bytes[inputIndex++] & 0x3f;
|
||||
|
||||
// this can be > 0xffff, so possibly generate surrogates
|
||||
let codepoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4;
|
||||
if (codepoint > 0xffff) {
|
||||
// codepoint &= ~0x10000;
|
||||
codepoint -= 0x10000;
|
||||
pending[pendingIndex++] = (codepoint >>> 10) & 0x3ff | 0xd800;
|
||||
codepoint = 0xdc00 | codepoint & 0x3ff;
|
||||
}
|
||||
pending[pendingIndex++] = codepoint;
|
||||
} else {
|
||||
// invalid initial byte
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Decoding a string is pretty slow, but use alternative options where possible.
|
||||
let decodeImpl = decodeFallback;
|
||||
if (typeof Buffer === 'function' && Buffer.from) {
|
||||
// Buffer.from was added in Node v5.10.0 (2015-11-17).
|
||||
decodeImpl = decodeBuffer;
|
||||
} else if (typeof Blob === 'function' && typeof URL === 'function' && typeof URL.createObjectURL === 'function') {
|
||||
// Blob and URL.createObjectURL are available from IE10, Safari 6, Chrome 19
|
||||
// (all released in 2012), Firefox 19 (2013), ...
|
||||
decodeImpl = decodeSyncXHR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {(!ArrayBuffer|!ArrayBufferView)} buffer
|
||||
* @param {{stream: boolean}=} options
|
||||
* @return {string}
|
||||
*/
|
||||
FastTextDecoder.prototype['decode'] = function(buffer, options={stream: false}) {
|
||||
if (options['stream']) {
|
||||
throw new Error(`Failed to decode: the 'stream' option is unsupported.`);
|
||||
}
|
||||
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
let bytes;
|
||||
|
||||
if (buffer instanceof Uint8Array) {
|
||||
// Accept Uint8Array instances as-is.
|
||||
bytes = buffer;
|
||||
} else if (buffer.buffer instanceof ArrayBuffer) {
|
||||
// Look for ArrayBufferView, which isn't a real type, but basically
|
||||
// represents all the valid TypedArray types plus DataView. They all have
|
||||
// ".buffer" as an instance of ArrayBuffer.
|
||||
bytes = new Uint8Array(buffer.buffer);
|
||||
} else {
|
||||
// The only other valid argument here is that "buffer" is an ArrayBuffer.
|
||||
// We also try to convert anything else passed to a Uint8Array, as this
|
||||
// catches anything that's array-like. Native code would throw here.
|
||||
bytes = new Uint8Array(buffer);
|
||||
}
|
||||
|
||||
return decodeImpl(/** @type {!Uint8Array} */ (bytes));
|
||||
}
|
||||
|
||||
scope['TextEncoder'] = FastTextEncoder;
|
||||
scope['TextDecoder'] = FastTextDecoder;
|
||||
|
||||
}(typeof window !== 'undefined' ? window : (typeof global !== 'undefined' ? global : this)));
|
||||
201
utils/polyfills/fast-text-encoding/LICENSE
Normal file
201
utils/polyfills/fast-text-encoding/LICENSE
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
1
utils/polyfills/fast-text-encoding/README
Normal file
1
utils/polyfills/fast-text-encoding/README
Normal file
|
|
@ -0,0 +1 @@
|
|||
See https://github.com/samthor/fast-text-encoding.
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018 Apple Inc. All rights reserved.
|
||||
* Copyright (C) 2018-2025 Apple Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
|
@ -27,10 +27,10 @@ const isInBrowser = false;
|
|||
if (typeof console == "undefined")
|
||||
console = {};
|
||||
|
||||
console.debug ??= (...args) => console.log("Debug:", ...args);
|
||||
console.debug ??= (...args) => printErr("Debug: " + args.join(" "));
|
||||
console.log ??= (...args) => print(args.join(" "));
|
||||
console.warn ??= (...args) => console.log("Warn:", ...args);
|
||||
console.error ??= (...args) => console.log("Error:", ...args);
|
||||
console.warn ??= (...args) => printErr("Warn: " + args.join(" "));
|
||||
console.error ??= (...args) => printErr("Error: " + args.join(" "));
|
||||
console.assert ??= (condition, message) => {
|
||||
if (!condition)
|
||||
throw new Error(`Assertion failed: ${message}`);
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -10,7 +10,7 @@
|
|||
# Finally `sudo dotnet workload install wasm-tools` (without sudo for a user
|
||||
# installation of dotnet, e.g., with option B above).
|
||||
|
||||
rm -r ./build-interp ./build-aot build.log
|
||||
rm -r src/dotnet/bin src/dotnet/obj ./build-interp ./build-aot build.log
|
||||
|
||||
touch build.log
|
||||
BUILD_LOG="$(realpath build.log)"
|
||||
|
|
@ -27,6 +27,14 @@ printf '%s\n' 'import.meta.url ??= "";' | cat - ./src/dotnet/bin/Release/net9.0/
|
|||
echo "Copying symbol maps..." | tee -a "$BUILD_LOG"
|
||||
cp ./src/dotnet/obj/Release/net9.0/wasm/for-publish/dotnet.native.js.symbols ./build-interp/wwwroot/_framework/
|
||||
|
||||
# Net9 and Net10 use Emscripten version 3.1.56, which emits legacy EH, see https://github.com/WebKit/JetStream/pull/188
|
||||
# FIXME: Update toolchain to Net11 once available, then remove this wasm-opt call.
|
||||
for wasmFile in $(find "./build-interp" -type f -name "*.wasm");
|
||||
do
|
||||
wasm-opt "$wasmFile" --translate-to-exnref --enable-bulk-memory --enable-exception-handling --enable-simd --enable-reference-types --enable-multivalue -o "$wasmFile"
|
||||
done
|
||||
|
||||
|
||||
echo "Building aot..." | tee -a "$BUILD_LOG"
|
||||
dotnet publish -o ./build-aot ./src/dotnet/dotnet.csproj -p:RunAOTCompilation=true
|
||||
|
||||
|
|
@ -34,3 +42,10 @@ dotnet publish -o ./build-aot ./src/dotnet/dotnet.csproj -p:RunAOTCompilation=tr
|
|||
printf '%s\n' 'import.meta.url ??= "";' | cat - ./build-aot/wwwroot/_framework/dotnet.js > temp.js && mv temp.js ./build-aot/wwwroot/_framework/dotnet.js
|
||||
echo "Copying symbol maps..." | tee -a "$BUILD_LOG"
|
||||
cp ./src/dotnet/obj/Release/net9.0/wasm/for-publish/dotnet.native.js.symbols ./build-aot/wwwroot/_framework/
|
||||
|
||||
# Net9 and Net10 use Emscripten version 3.1.56, which emits legacy EH, see https://github.com/WebKit/JetStream/pull/188
|
||||
# FIXME: Update toolchain to Net11 once available, then remove this wasm-opt call.
|
||||
for wasmFile in $(find "./build-aot" -type f -name "*.wasm");
|
||||
do
|
||||
wasm-opt "$wasmFile" --translate-to-exnref --enable-bulk-memory --enable-exception-handling --enable-simd --enable-reference-types --enable-multivalue -o "$wasmFile"
|
||||
done
|
||||
|
|
|
|||
Loading…
Reference in a new issue