Skip to content

Commit

Permalink
プチフリ調査
Browse files Browse the repository at this point in the history
  • Loading branch information
山田元康m_yamada@spicysoft.com committed Mar 20, 2019
1 parent a7ac4e2 commit cbc881e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Main.ts
Expand Up @@ -264,6 +264,7 @@ class Main extends eui.UILayer {

private eraseBlocksOutOfCamera() {
const visibilityLeft = this.cameraX - this.width / 2;
const start = performance.now();
this.platforms = this.platforms.filter(p => {
const r = p.x + p.width;
const inCamera = visibilityLeft <= r;
Expand All @@ -272,6 +273,10 @@ class Main extends eui.UILayer {
}
return inCamera;
});
const cost = performance.now() - start;
if (1 < cost) {
egret.log(`Rm c:${cost}`);
}
}

private drawPlatformGenerationMode(): PlatformGenerationMode {
Expand All @@ -292,7 +297,7 @@ class Main extends eui.UILayer {
private generateNewBlocks() {
const generationBorder = this.cameraX + this.width;
while (this.lastDrawnX < generationBorder) {
const start = new Date().getMilliseconds();
const start = performance.now();

const mode = this.drawPlatformGenerationMode();

Expand Down Expand Up @@ -363,8 +368,8 @@ class Main extends eui.UILayer {
}
break;
}
const cost = new Date().getMilliseconds() - start;
egret.log(`mode: ${mode}, cost: ${cost}`);
const cost = performance.now() - start;
egret.log(`Gen m: ${mode}, c: ${cost}`);
}
}

Expand Down

0 comments on commit cbc881e

Please sign in to comment.