-
Couldn't load subscription status.
- Fork 17
New Workload: Babylon class-heavy workload #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
camillobruni
wants to merge
34
commits into
WebKit:main
Choose a base branch
from
camillobruni:2025-08-14_class-startup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+111,108
−0
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
44dc65e
lde
camillobruni 6e091fc
add more
camillobruni 5ec829b
adding config
camillobruni 48c6a4e
update
camillobruni 09cc4ea
update
camillobruni 13dcbf5
updated
camillobruni 6837ae3
update
camillobruni 35375b3
more code
camillobruni 007541d
prject cleanup
camillobruni 89144fd
update
camillobruni 5cea008
add LICENSE plugin
camillobruni 402bdee
re-adding files
camillobruni 856dad5
adding more files
camillobruni 8d90481
adding more files
camillobruni ca40cf5
adding sourc
camillobruni 27dbbe1
update
camillobruni a1202df
fixes
camillobruni d45117d
updating tests
camillobruni 7cba4cd
gupdate
camillobruni 478a404
Merge branch 'main' into 2025-08-14_class-startup
camillobruni d71e415
adding bundles
camillobruni 56bb6e8
updating config
camillobruni 8024b3a
Merge branch 'main' into 2025-08-14_class-startup
camillobruni 8dcaace
- add license
camillobruni 4503709
add esm webpack config
camillobruni a564fae
fix runs
camillobruni 527c352
Merge branch 'main' into 2025-08-14_class-startup
camillobruni cb66bc1
update webpack config
camillobruni 16d2374
update es5 vs es5 config
camillobruni 94b2409
Merge branch 'main' into 2025-08-14_class-startup
camillobruni 39e8b49
fix typo
camillobruni 46e48de
Merge branch 'main' of github.com:camillobruni/JetStream into 2025-08…
camillobruni b1720f8
updating workload
camillobruni 979349e
add tags
camillobruni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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}`); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { runTest } from "../src/babylon-js-benchmark.mjs"; | ||
|
|
||
| console.log(runTest()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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}`); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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(); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.