Commit 61844664 authored by wildfirecode's avatar wildfirecode

update

parents
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src="index.js"></script>
<script>
window.__fpscallback__ = (fps) => {
console.log(`fps=${fps}`)
}
__startFpsFunc__()
</script>
</body>
</html>
\ No newline at end of file
"use strict";
(function () {
var beginTime = (performance || Date).now();
var prevTime = beginTime;
var frames = 0;
var MAX = 2;
var count = MAX;
var totalFrames = 0;
var begin = function () {
beginTime = (performance || Date).now();
};
var end = function () {
frames++;
var time = (performance || Date).now();
if (time >= prevTime + 1000) {
console.log(frames);
totalFrames += frames;
count--;
prevTime = time;
frames = 0;
}
return count;
};
var animate = function () {
begin();
var count = end();
if (count == 0) {
var fps = Math.floor(totalFrames / MAX);
window['__fpscallback__'] && window['__fpscallback__'](fps);
return;
}
requestAnimationFrame(animate);
};
window['__startFpsFunc__'] = function () {
beginTime = (performance || Date).now();
prevTime = beginTime;
animate();
};
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment