Skip to content

Commit

Permalink
gl.js: use performance timer
Browse files Browse the repository at this point in the history
Use performance.now instead of Date.now, which may provide a
higher-resolution time (depending on the browser's Spectre mitigation
settings). Add performance.timeOrigin so that the returned value is
still relative to the Unix epoch.
  • Loading branch information
troyc committed Dec 14, 2022
1 parent 124aca8 commit fccf5e3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion js/gl.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ var importObject = {
return Math.floor(Math.random() * 2147483647);
},
now: function () {
return Date.now() / 1000.0;
return (performance.timeOrigin + performance.now()) / 1000.0
},
canvas_width: function () {
return Math.floor(canvas.width);
Expand Down

0 comments on commit fccf5e3

Please sign in to comment.