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
89 changes: 89 additions & 0 deletions examples/tests/stress-multi-level.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2023 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.
*/

import { type INode } from '@lightningjs/renderer';
import logo from '../assets/lightning.png';
import type { ExampleSettings } from '../common/ExampleSettings.js';

const randomIntBetween = (from: number, to: number) =>
Math.floor(Math.random() * (to - from + 1) + from);

export default async function ({
renderer,
testRoot,
perfMultiplier,
}: ExampleSettings) {
// create nodes
const numOuterNodes = 100 * perfMultiplier;
const nodes: INode[] = [];
let totalNodes = 0;

const bg = renderer.createNode({
width: 1920,
height: 1080,
color: 0xff1e293b,
parent: testRoot,
});

for (let i = 0; i < numOuterNodes; i++) {
const container = renderer.createNode({
x: Math.random() * 1920,
y: Math.random() * 1080,
parent: bg,
});
const node = renderer.createNode({
width: 505,
height: 101,
src: logo,
parent: container,
});

nodes.push(container);
totalNodes += 2;
}

console.log(
`Created ${numOuterNodes} outer nodes with another node nested inside. Total nodes: ${totalNodes}`,
);

// create 100 animations
const animate = () => {
nodes.forEach((node) => {
node
.animate(
{
x: randomIntBetween(20, 1740),
y: randomIntBetween(20, 900),
rotation: Math.random() * Math.PI,
},
{
duration: 3000,
easing: 'ease-out',
loop: true,
stopMethod: 'reverse',
},
)
.start();
});
};

animate();

// setInterval(animate, 3000);
}
92 changes: 92 additions & 0 deletions examples/tests/stress-multi-texture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2023 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.
*/

import { type INode } from '@lightningjs/renderer';
import logo from '../assets/lightning.png';
import robot from '../assets/robot/robot.png';

import type { ExampleSettings } from '../common/ExampleSettings.js';

const randomIntBetween = (from: number, to: number) =>
Math.floor(Math.random() * (to - from + 1) + from);

export default async function ({
renderer,
testRoot,
perfMultiplier,
}: ExampleSettings) {
// create nodes
const numOuterNodes = 100 * perfMultiplier;
const nodes: INode[] = [];

const bg = renderer.createNode({
width: 1920,
height: 1080,
color: 0xff1e293b,
parent: testRoot,
});

for (let i = 0; i < numOuterNodes; i++) {
const node = renderer.createNode({
x: Math.random() * 1920,
y: Math.random() * 1080,
...(i % 2 === 0
? {
width: 505,
height: 101,
src: logo,
}
: {
width: 140,
height: 140,
src: robot,
}),
parent: bg,
});

nodes.push(node);
}

console.log(`Created ${numOuterNodes} nodes with alternating textures`);

// create animations
const animate = () => {
nodes.forEach((node) => {
node
.animate(
{
x: randomIntBetween(20, 1740),
y: randomIntBetween(20, 900),
rotation: Math.random() * Math.PI,
},
{
duration: 3000,
easing: 'ease-out',
loop: true,
stopMethod: 'reverse',
},
)
.start();
});
};

animate();

// setInterval(animate, 3000);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default async function ({
perfMultiplier,
}: ExampleSettings) {
// create 100 nodes
const numOuterNodes = 100 * perfMultiplier;
const nodes: INode[] = [];

const bg = renderer.createNode({
Expand All @@ -39,7 +40,7 @@ export default async function ({
parent: testRoot,
});

for (let i = 0; i < 100 * perfMultiplier; i++) {
for (let i = 0; i < numOuterNodes; i++) {
const node = renderer.createNode({
width: 505,
height: 101,
Expand All @@ -52,6 +53,8 @@ export default async function ({
nodes.push(node);
}

console.log(`Created ${numOuterNodes} nodes with the same texture`);

// create 100 animations
const animate = () => {
nodes.forEach((node) => {
Expand Down