为什么我的计时代码总是返回0?
我正在优化我的 html5 游戏引擎以解决性能问题,我想知道渲染过程需要多少时间。所以我得到了一堆渲染函数。每个渲染函数都渲染游戏的单独部分..例如块,玩家等。
function gameRender() {
var d1 = new Date();
var firstTime = d1.getTime();
// render stuff
var second = d1.getTime();
console.log("Renders took " + (second-firstTime));
}
i was optimizing my html5 game engine for performance issues and i want to know how much time a render process needs.So i got a bunch of render functions.Each of them render seperated parts of the game.. such as blocks , players etc.
function gameRender() {
var d1 = new Date();
var firstTime = d1.getTime();
// render stuff
var second = d1.getTime();
console.log("Renders took " + (second-firstTime));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,我遇到了问题:在 Google 上进行了一些搜索后,我意识到我必须为第二个变量使用第二个日期对象,所以这里是一个固定版本:
Hmm I got the problem: after a little search on Google , I realized that I must use a second date object for the second variable, so here is a fixed version: