Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frameworks/blits/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Blits from '@lightningjs/blits'
import Benchmark from './pages/Benchmark.js'
import Memory from './pages/Memory.js'
import Rectangles from './pages/Rectangles.js'
import Images from './pages/Images.js'
import symbols from '@lightningjs/blits/symbols'
import { setRenderer } from './perf.js'

Expand All @@ -37,6 +38,7 @@ export default Blits.Application({
// cold-startup measurement instead of the throughput sequence.
{ path: '/startup', component: Benchmark },
{ path: '/rectangles', component: Rectangles },
{ path: '/images', component: Images },
],
hooks: {
async ready() {
Expand Down
62 changes: 62 additions & 0 deletions frameworks/blits/src/pages/Images.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2024 Comcast Cable Communications Management, LLC
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/

import Blits from '@lightningjs/blits'
import { runImageBenchmark } from '../../../../shared/imageBenchmark.js'
import { createBlitsImageLoader, blitsImageEventReceived } from '../../../../shared/imagePlatformAdapters.js'

export default Blits.Component('Images', {
template: `
<Element>
<Element
:for="img in $images"
:src="$img.src"
:x="$img.x"
:y="$img.y"
:w="$img.w"
:h="$img.h"
key="$img.src"
@loaded="onImageLoaded"
@error="onImageError"
/>
</Element>
`,
state() {
return {
images: [],
imageLoadedCount: 0,
imageErrorCount: 0,
}
},
hooks: {
ready() {
runImageBenchmark({
loadImages: createBlitsImageLoader(this),
}).catch((error) => console.error('Image benchmark failed:', error))
},
},
methods: {
onImageLoaded() {
this.imageLoadedCount++
blitsImageEventReceived(this)
},
onImageError() {
this.imageErrorCount++
blitsImageEventReceived(this)
},
},
})
2 changes: 1 addition & 1 deletion frameworks/ftl-canvas-bitmap/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</style>
</head>
<body>
<canvas width="1900" height="1080"></canvas>
<canvas width="1920" height="1080"></canvas>
<script type="module" src="index.js"></script>
</body>
</html>
5 changes: 4 additions & 1 deletion frameworks/ftl-canvas-bitmap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { warmup } from '../../shared/utils/warmup.js';
import { reportStartup } from '../../shared/utils/startup.js';
import { run } from '../../shared/utils/run.js';
import { runFtlRectangleBenchmark } from '../../shared/rectanglePlatformAdapters.js';
import { runFtlImageBenchmark } from '../../shared/imagePlatformAdapters.js';


const canvas = document.querySelector('canvas')
Expand Down Expand Up @@ -36,7 +37,7 @@ const app = renderer({
numImageWorkers: 0,
}
});
const { root, createElement, createText, signals, loadFont } = app;
const { root, createElement, createText, createImage, signals, loadFont } = app;

const fontLoadedPromise = loadFont('bitmap', {
family: 'ArialBMF',
Expand Down Expand Up @@ -379,6 +380,8 @@ fontLoadedPromise.then(() => {
runStartupBenchmark();
} else if (hash === 'rectangles') {
runFtlRectangleBenchmark({ app, root: rootNode, signals, createElement });
} else if (hash === 'images') {
runFtlImageBenchmark({ root, createElement, createImage });
} else {
runBenchmark();
}
Expand Down
2 changes: 1 addition & 1 deletion frameworks/ftl-canvas/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</style>
</head>
<body>
<canvas width="1900" height="1080"></canvas>
<canvas width="1920" height="1080"></canvas>
<script type="module" src="index.js"></script>
</body>
</html>
5 changes: 4 additions & 1 deletion frameworks/ftl-canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { warmup } from '../../shared/utils/warmup.js';
import { reportStartup } from '../../shared/utils/startup.js';
import { run } from '../../shared/utils/run.js';
import { runFtlRectangleBenchmark } from '../../shared/rectanglePlatformAdapters.js';
import { runFtlImageBenchmark } from '../../shared/imagePlatformAdapters.js';

const canvas = document.querySelector('canvas')
if (window.location.hash === '#rectangles') {
Expand All @@ -34,7 +35,7 @@ const app = renderer({
maxTextureCount: 4096,
}
});
const { root, createElement, createText, signals } = app;
const { root, createElement, createText, createImage, signals } = app;

const colours = [
[1.0, 0.0, 0.0, 1.0], // red
Expand Down Expand Up @@ -366,6 +367,8 @@ if (hash === 'memory') {
runStartupBenchmark();
} else if (hash === 'rectangles') {
runFtlRectangleBenchmark({ app, root: rootNode, signals, createElement });
} else if (hash === 'images') {
runFtlImageBenchmark({ root, createElement, createImage });
} else {
runBenchmark();
}
2 changes: 1 addition & 1 deletion frameworks/ftl-webgl-bitmap/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</style>
</head>
<body>
<canvas width="1900" height="1080"></canvas>
<canvas width="1920" height="1080"></canvas>
<script type="module" src="index.js"></script>
</body>
</html>
5 changes: 4 additions & 1 deletion frameworks/ftl-webgl-bitmap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { warmup } from '../../shared/utils/warmup.js';
import { reportStartup } from '../../shared/utils/startup.js';
import { run } from '../../shared/utils/run.js';
import { runFtlRectangleBenchmark } from '../../shared/rectanglePlatformAdapters.js';
import { runFtlImageBenchmark } from '../../shared/imagePlatformAdapters.js';

const borderShader = createShader(BorderShader);
borderShader.width = 1;
Expand Down Expand Up @@ -45,7 +46,7 @@ const app = renderer({
numImageWorkers: 0,
}
});
const { root, createElement, createText, signals, loadFont } = app;
const { root, createElement, createText, createImage, signals, loadFont } = app;

const fontLoadedPromise = loadFont('bitmap', {
family: 'ArialBMF',
Expand Down Expand Up @@ -388,6 +389,8 @@ fontLoadedPromise.then(() => {
runStartupBenchmark();
} else if (hash === 'rectangles') {
runFtlRectangleBenchmark({ app, root: rootNode, signals, createElement, RectShader: BorderShader, createShader, rectShader: borderShader });
} else if (hash === 'images') {
runFtlImageBenchmark({ root, createElement, createImage });
} else {
runBenchmark();
}
Expand Down
2 changes: 1 addition & 1 deletion frameworks/ftl/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</style>
</head>
<body>
<canvas width="1900" height="1080"></canvas>
<canvas width="1920" height="1080"></canvas>
<script type="module" src="index.js"></script>
</body>
</html>
5 changes: 4 additions & 1 deletion frameworks/ftl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { warmup } from '../../shared/utils/warmup.js';
import { reportStartup } from '../../shared/utils/startup.js';
import { run } from '../../shared/utils/run.js';
import { runFtlRectangleBenchmark } from '../../shared/rectanglePlatformAdapters.js';
import { runFtlImageBenchmark } from '../../shared/imagePlatformAdapters.js';

const outlineShader = createShader(OutlineShader);
outlineShader.width = 1;
Expand Down Expand Up @@ -47,7 +48,7 @@ const app = renderer({
numImageWorkers: 0
}
});
const { root, createElement, createText, signals, loadFont } = app;
const { root, createElement, createText, createImage, signals, loadFont } = app;


const colours = [
Expand Down Expand Up @@ -401,6 +402,8 @@ if (hash === 'memory') {
runStartupBenchmark();
} else if (hash === 'rectangles') {
runFtlRectangleBenchmark({ app, root: rootNode, signals, createElement, RectShader: OutlineShader, createShader, rectShader: outlineShader });
} else if (hash === 'images') {
runFtlImageBenchmark({ root, createElement, createImage });
} else {
runBenchmark();
}
7 changes: 7 additions & 0 deletions frameworks/lightning2-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { warmup } from '../../shared/utils/warmup';
import { reportStartup } from '../../shared/utils/startup.js';
import { run } from '../../shared/utils/run.js';
import { runRectangleBenchmark } from '../../shared/rectangleBenchmark.js';
import { runLightning2ImageBenchmark } from '../../shared/imagePlatformAdapters.js';

// apply CSS styling
const style = document.createElement('style');
Expand Down Expand Up @@ -82,6 +83,8 @@ export class App extends Lightning.Application {
const hash = window.location.hash.substring(1);
if (hash === 'rectangles') {
this.runRectangleBenchmark();
} else if (hash === 'images') {
this.runImageBenchmark();
} else if (hash === 'memory') {
console.log('Running memory benchmark');
this.createMemoryBenchmark();
Expand All @@ -93,6 +96,10 @@ export class App extends Lightning.Application {
}
}

async runImageBenchmark() {
await runLightning2ImageBenchmark({ Lightning, app: this });
}

async runRectangleBenchmark() {
const items = this.tag('Items').childList;
await runRectangleBenchmark({
Expand Down
7 changes: 7 additions & 0 deletions frameworks/lightning2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { warmup } from '../../shared/utils/warmup.js';
import { reportStartup } from '../../shared/utils/startup.js';
import { run } from '../../shared/utils/run.js';
import { runRectangleBenchmark } from '../../shared/rectangleBenchmark.js';
import { runLightning2ImageBenchmark } from '../../shared/imagePlatformAdapters.js';

// apply CSS styling
const style = document.createElement('style');
Expand Down Expand Up @@ -130,6 +131,8 @@ export class App extends Lightning.Application {
const hash = window.location.hash.substring(1);
if (hash === 'rectangles') {
this.runRectangleBenchmark();
} else if (hash === 'images') {
this.runImageBenchmark();
} else if (hash === 'memory') {
console.log('Running memory benchmark');
this.createMemoryBenchmark();
Expand All @@ -141,6 +144,10 @@ export class App extends Lightning.Application {
}
}

async runImageBenchmark() {
await runLightning2ImageBenchmark({ Lightning, app: this });
}

async runRectangleBenchmark() {
const items = this.tag('Items').childList;
await runRectangleBenchmark({
Expand Down
3 changes: 3 additions & 0 deletions frameworks/renderer-canvasfonts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { waitUntilIdle } from '../../shared/utils/waitUntilIdle.js';
import { reportStartup } from '../../shared/utils/startup.js';
import { run } from '../../shared/utils/run.js';
import { runRendererRectangleBenchmark } from '../../shared/rectanglePlatformAdapters.js';
import { runRendererImageBenchmark } from '../../shared/imagePlatformAdapters.js';

const rectangleMode = window.location.hash === '#rectangles';
const appHeight = rectangleMode ? 540 : 1080;
Expand Down Expand Up @@ -385,6 +386,8 @@ if (hash === 'memory') {
runStartupBenchmark();
} else if (hash === 'rectangles') {
runRendererRectangleBenchmark(renderer, rootNode);
} else if (hash === 'images') {
runRendererImageBenchmark(renderer, rootNode);
} else {
runBenchmark();
}
3 changes: 3 additions & 0 deletions frameworks/renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { waitUntilIdle } from '../../shared/utils/waitUntilIdle.js';
import { reportStartup } from '../../shared/utils/startup.js';
import { run } from '../../shared/utils/run.js';
import { runRendererRectangleBenchmark } from '../../shared/rectanglePlatformAdapters.js';
import { runRendererImageBenchmark } from '../../shared/imagePlatformAdapters.js';

const rectangleMode = window.location.hash === '#rectangles';
const appHeight = rectangleMode ? 540 : 1080;
Expand Down Expand Up @@ -407,6 +408,8 @@ if (hash === 'memory') {
runStartupBenchmark();
} else if (hash === 'rectangles') {
runRendererRectangleBenchmark(renderer, rootNode, Border);
} else if (hash === 'images') {
runRendererImageBenchmark(renderer, rootNode);
} else {
runBenchmark();
}
16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { processResults, processStartupResults } from "./testrunner/processResul
import { writeResults } from "./testrunner/writeResults.js";
import { getJavaScriptBundleSize } from "./testrunner/totalBundlefileSize.js";
import { runRectangleBenchmarks } from "./testrunner/runRectangles.js";
import { runImageBenchmarks } from "./testrunner/runImages.js";


/**
Expand All @@ -48,6 +49,7 @@ if (args.includes('--results') || args.includes('-r')) {
*/
const startupOnlyFlag = args.includes('--startup-only');
const rectanglesOnlyFlag = args.includes('--rectangles');
const imagesOnlyFlag = args.includes('--images');

/**
* Checks if the './dist' directory exists.
Expand Down Expand Up @@ -114,6 +116,8 @@ const lookupFrameworkVersion = (dir) => {
*/
const dirs = fs.readdirSync('./dist', { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
// skip non-framework dirs such as dist/images (benchmark image assets)
.filter(dirent => fs.existsSync(`./dist/${dirent.name}/index.html`))
.map(dirent => dirent.name);

/**
Expand Down Expand Up @@ -165,6 +169,7 @@ let fileSizeResults = null;
*/
let startupResults = null;
const rectangleResults = {};
const imageResults = {};
let idx = 0;

/**
Expand All @@ -178,6 +183,11 @@ if (rectanglesOnlyFlag) {
process.exit(0);
}

if (imagesOnlyFlag) {
await runImageBenchmarks(dirs, browserVersion);
process.exit(0);
}

/**
* Initializes the results object.
* @typedef {import('./testrunner/types/results.js').Result} Result
Expand Down Expand Up @@ -236,6 +246,10 @@ const run = async (dir) => {
console.log(`Running rectangle rendering benchmarks for ${dir}...`);
const frameworkRectangles = await runRectangleBenchmarks([dir], browserVersion);
Object.assign(rectangleResults, frameworkRectangles.results);

console.log(`Running image loading benchmarks for ${dir}...`);
const frameworkImages = await runImageBenchmarks([dir], browserVersion);
Object.assign(imageResults, frameworkImages.results);
}

idx++;
Expand Down Expand Up @@ -279,7 +293,7 @@ const run = async (dir) => {
return;
}

const processedResults = processResults(results, memoryResults, fileSizeResults, startupResults, rectangleResults);
const processedResults = processResults(results, memoryResults, fileSizeResults, startupResults, rectangleResults, imageResults);
console.log('All benchmarks done!');
console.log('Processed results:');
console.log(processedResults);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"setup:playwright": "npx playwright install",
"start": "concurrently --kill-others --success last \"npx http-server -c-1 ./dist/\" \"node index.js\"",
"start:official": "concurrently --kill-others --success last \"npx http-server -c-1 ./dist/\" \"node index.js --results\"",
"rectangles": "node index.js --rectangles"
"rectangles": "node index.js --rectangles",
"images": "node index.js --images"
},
"author": "",
"license": "MIT",
Expand Down
Loading