diff --git a/pages/API/animation-frame/animation-frame.uvue b/pages/API/animation-frame/animation-frame.uvue index 4d1ea94ceb0197201a304c1d8f9d79328f3b0897..f9502ee74a9e30a8267b191235a0b7f8388dbbb1 100644 --- a/pages/API/animation-frame/animation-frame.uvue +++ b/pages/API/animation-frame/animation-frame.uvue @@ -3,7 +3,7 @@ - FPS: {{fps}} + FPS: {{fps}} / {{formatFPSTime}} FrameCount: {{testFrameCount}} 提示: 在当前测试例子中,每增加一次调用 requestAnimationFrame 帧率翻倍,cancelAnimationFrame 后恢复 @@ -15,7 +15,8 @@ return { title: 'AnimationFrame', taskId: 0, - fps: 0, + fps: 0, + formatFPSTime: '0ms', lastTime: 0, frameCount: 0, testFrameCount: 0 @@ -30,7 +31,8 @@ startRequestAnimationFrame() { this.taskId = requestAnimationFrame((timestamp : number) => { this.frameCount++ - if (timestamp - this.lastTime >= 1000) { + if (timestamp - this.lastTime >= 1000) { + this.formatFPSTime = (1000 / this.frameCount).toFixed(3) + 'ms' this.fps = this.frameCount this.frameCount = 0 this.lastTime = timestamp @@ -42,6 +44,7 @@ }, stopRequestAnimationFrame() { this.fps = 0 + this.formatFPSTime = '0ms' this.lastTime = 0 this.frameCount = 0 cancelAnimationFrame(this.taskId)