mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-07-22 01:55:25 -04:00
3846a1553b
Co-authored-by: Davy Hélard <davy.helard@gmail.com> Don't show in changelog
57 lines
1.9 KiB
JavaScript
57 lines
1.9 KiB
JavaScript
describe('gdjs.RuntimeObject', function() {
|
|
const runtimeGame = gdjs.getPixiRuntimeGame();
|
|
const runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
|
|
|
it('benchmark getAABB of rotated vs non rotated objects', function(){
|
|
this.timeout(20000);
|
|
var object = new gdjs.RuntimeObject(runtimeScene, {name: "obj1", type: "", behaviors: [], effects: []});
|
|
object.getWidth = function() { return 10; };
|
|
object.getHeight = function() { return 20; };
|
|
object.setPosition(15, 20);
|
|
|
|
const benchmarkSuite = makeBenchmarkSuite({
|
|
benchmarksCount: 60,
|
|
iterationsCount: 60000,
|
|
});
|
|
benchmarkSuite
|
|
.add('getAABB of a non rotated, default center', (i) => {
|
|
object.setX(i);
|
|
object.getAABB();
|
|
})
|
|
.add('getAABB of a rotated, default center', (i) => {
|
|
object.setX(i);
|
|
object.getAABB();
|
|
});
|
|
|
|
console.log(benchmarkSuite.run());
|
|
});
|
|
|
|
it('benchmark getAABB of rotated vs non rotated objects, with non default center', function(){
|
|
this.timeout(20000);
|
|
var object = new gdjs.RuntimeObject(runtimeScene, {name: "obj1", type: "", behaviors: [], effects: []});
|
|
object.getWidth = function() { return 10; };
|
|
object.getHeight = function() { return 20; };
|
|
object.getCenterX = function() { return 0 };
|
|
object.getCenterY = function() { return 0 };
|
|
object.setPosition(15, 20);
|
|
|
|
const benchmarkSuite = makeBenchmarkSuite({
|
|
benchmarksCount: 60,
|
|
iterationsCount: 60000,
|
|
});
|
|
benchmarkSuite
|
|
.add('getAABB of a non rotated, non default center', (i) => {
|
|
object.setAngle(0);
|
|
object.setX(i);
|
|
object.getAABB();
|
|
})
|
|
.add('getAABB of a rotated, non default center', (i) => {
|
|
object.setAngle(90);
|
|
object.setX(i);
|
|
object.getAABB();
|
|
});
|
|
|
|
console.log(benchmarkSuite.run());
|
|
});
|
|
});
|