Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !function() {
- var times = [];
- var fps;
- var fpselm = document.createElement('p');
- fpselm.setAttribute('style', 'all: initial; position: fixed; top: 0px; right: 0px; font-family: Arial; font-size: 20px; z-index: 2000000000; background: #ffffff80; color: black; margin: 0px; pointer-events: none');
- document.body.append(fpselm);
- function loop() {
- window.requestAnimationFrame(function() {
- const now = performance.now();
- while (times.length > 0 && times[0] <= now - 1000) {
- times.shift();
- }
- times.push(now);
- fps = times.length;
- loop();
- });
- };
- setInterval(function() {
- fpselm.innerText = `${fps} FPS`
- }, 1000);
- loop();
- }();
Advertisement
Comments
-
- console.log("you forgot to also use JavaScript as Syntax Highlighting lol")
-
- it's just some colors but it's now fixed
-
- it's easier to read code with Syntax Highlighting
Add Comment
Please, Sign In to add comment
Advertisement