Files
GDevelop/GDJS/tests/benchmarks/runtimeobject.js
T
Harsimran Singh Virk 599ccb677f Add support for visual effects ("shaders") on objects. (#2901)
* This allows to generate interesting visual effects, which can be controlled by events. For example, you can use an outline on an object to highlight, make the player glow when launching a spell, blur objects, etc...
* A new "effects" tab is now present in the objects editor. From there, you can add visual effects, that were already available for layers, customize them from this editor.
* Actions and conditions are available to manipulate effects and change their parameters during the game.
* Learn more on the wiki: http://wiki.compilgames.net/doku.php/gdevelop5/objects/effects

Co-authored-by: Florian Rival <Florian.Rival@gmail.com>
2021-08-20 15:01:06 +02:00

56 lines
1.9 KiB
JavaScript

describe('gdjs.RuntimeObject', function() {
const runtimeScene = new gdjs.RuntimeScene(null);
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());
});
});