mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
wip: 20_000 test
This commit is contained in:
@@ -2,6 +2,28 @@
|
||||
(function (Renderer) {
|
||||
console.log("preamble", Renderer);
|
||||
|
||||
const LCG_MULTIPLIER = 1103515245;
|
||||
const LCG_INCREMENT = 12345;
|
||||
const LCG_MODULUS = Math.pow(2, 31);
|
||||
const LCG_MASK = (LCG_MODULUS - 1);
|
||||
|
||||
function lcg(x, a, c, m) {
|
||||
return (x * a + c) % m;
|
||||
}
|
||||
|
||||
class Random {
|
||||
constructor(seed) {
|
||||
this._seed = seed;
|
||||
}
|
||||
|
||||
value() {
|
||||
this._seed = lcg(this._seed, LCG_MULTIPLIER, LCG_INCREMENT, LCG_MODULUS);
|
||||
return (this._seed & LCG_MASK) / LCG_MODULUS;
|
||||
}
|
||||
}
|
||||
|
||||
const random = new Random(0)
|
||||
|
||||
// Sets canvas.
|
||||
Renderer.setCanvas = function setCanvas(canvas, attrs) {
|
||||
const context = GL.createContext(canvas, attrs);
|
||||
@@ -19,19 +41,29 @@
|
||||
};
|
||||
|
||||
Renderer.setObjects = function setObjects(vbox, zoom, objects) {
|
||||
this._SetObjects(objects.cnt);
|
||||
for (let index = 0; index < objects.cnt; index++) {
|
||||
const object = objects.arr[index * 2 + 1];
|
||||
this._SetObject(
|
||||
// this._SetObjects(objects.cnt);
|
||||
const numObjects = 20_000;
|
||||
this._SetObjects(numObjects);
|
||||
for (let index = 0; index < numObjects; index++) {
|
||||
// const object = objects.arr[index * 2 + 1];
|
||||
this._SetObjectRect(
|
||||
index,
|
||||
object.selrect.x,
|
||||
object.selrect.y,
|
||||
object.selrect.width,
|
||||
object.selrect.height,
|
||||
// object.selrect.x,
|
||||
random.value() * 2000,
|
||||
// object.selrect.y,
|
||||
random.value() * 2000,
|
||||
// object.selrect.width,
|
||||
random.value() * 200,
|
||||
// object.selrect.height,
|
||||
random.value() * 200
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Renderer.drawCanvas = function drawCanvas(vbox, zoom, objects) {
|
||||
performance.mark('draw-canvas:start');
|
||||
this._DrawCanvas(vbox.x, vbox.y, zoom);
|
||||
performance.mark('draw-canvas:end');
|
||||
const { duration } = performance.measure('draw-canvas', 'draw-canvas:start', 'draw-canvas:end');
|
||||
console.log('draw-canvas', `${duration}ms`);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user