itteerde / fvttconfig

Configuration for our Foundry VTT environments
2 stars 1 forks source link

Performance Measurements and Comparisons #161

Closed itteerde closed 11 months ago

itteerde commented 1 year ago

Establish performance indicators, and make them useable, regression testing and testing if improvements are improvements indeeed.

itteerde commented 1 year ago
  1. Install system (and only that).
  2. Create scene "start", all defaults accepted (hope those are the same for both systems). Remove Token Vision.

dnd5e

  1. Create new Actor "pc1", Player Character, all defaults.
  2. Create new Actor "npc1", Non-Player Character, all defaults.
  3. Puth 1 Token for "pc1" and 100 Tokens for "npc1" on "start".
  4. Move "npc1" with computer game like expectation of responsiveness.
    1. No decernable lag at all.

cpr

  1. Create new Actor "pc1", Player Character, all defaults.
  2. Create new Actor "npc1", Mook, all defaults.
  3. Puth 1 Token for "pc1" and 100 Tokens for "npc1" on "start".
  4. Move "npc1" with computer game like expectation of responsiveness.
    1. No decernable lag at all.
itteerde commented 1 year ago

One difference that is there already with the fresh 101 is that in dnd5e the block of 100 can be moved without any perceivable lag, too, while in cpr moving that block of 100 Tokens has a clear lag -- though not at all an alarming one in itself (probably below 1s, that should be measureable easy enough with using a Macro to move them [@itteerde Write that Macro!]). The comparison however might be relevant.

so what to call for the movement in a measured context (Macro)?: https://discord.com/channels/170995199584108546/699750150674972743/1148278914230276199

itteerde commented 1 year ago

the simple highest level macro

const start = performance.now();
await canvas.tokens.moveMany({ dx: 1, dy: 1 });
console.log(`time measured: ${performance.now() - start}ms`);
itteerde commented 1 year ago

first line each: PC selected, second line each: all Mooks/NPCs selected CPR 101 tokens (1 PC, 100 Mooks) at otherwise empty scene image DND 101 (1 PC, 100 NPC) tokens at otherwise empty scene image the explosion here is only in moving the many, but there is a significant hit to moving just the one PC, too. Next step should be to demonstrate a condition where that moving one explodes, too -- as it did in the game blocking/ session aborting scene.

itteerde commented 1 year ago

looking into any kinds of warming up or building up blockage scenarios

CPR, moving the 1 PC repeatedly image

DND, moving the 1 PC repeatedly image

oh!

itteerde commented 1 year ago

pf2e image

itteerde commented 1 year ago

Measurements of ~0ms are hitting the macro to quickly. Other than that I think the numbers are reliable enough.

itteerde commented 1 year ago

image

itteerde commented 1 year ago

full text search indicates that the registering hooks section is complete, and no other registering is hidden anywhere

in cpr.js

registerHooks();

calling hooks.js

export default function registerHooks() {
  actorHooks.default();
  actorSheetHooks.default();
  chatHooks.default();
  folderHooks.default();
  itemHooks.default();
  tokenHudHooks.default();
  uiHooks.default();
  hotbarHooks.default();
  tokenHooks.default();
  externalHooks.default();
}
itteerde commented 1 year ago

therefore WTF?! indeed. The answer probably being polymorphism.

itteerde commented 1 year ago

What is happening here? Is it really destroying the old one and making a new one? And it is doing it for every Token, despite only one requiring to be mutated?

image

itteerde commented 1 year ago

how can it be 1/2 time today? I mean that is still to slow, but it is way faster than ever before. image

itteerde commented 1 year ago

Not really getting anywhere, next step destructive testing trying to get some idea what at all is making an impact, an in parallel reading the whole Foundry code.