admin管理员组文章数量:1353147
I would like to use performance.now() as seen in the top answer to this SO Post.
How to measure time taken by a function to execute
However is it was not available in my Replit or my local Node server.
Do I have to install it?
I searched packages on Repl.it and this came up
In the repl.it I added ...
const performance = require('performance'); const t0 = performance.now();
and it auto installed performance but I am still getting an error ... now it is saying that now() is not a function.
I would like to use performance.now() as seen in the top answer to this SO Post.
How to measure time taken by a function to execute
However is it was not available in my Replit or my local Node server.
Do I have to install it?
I searched packages on Repl.it and this came up
In the repl.it I added ...
const performance = require('performance'); const t0 = performance.now();
and it auto installed performance but I am still getting an error ... now it is saying that now() is not a function.
Share Improve this question edited Feb 23, 2020 at 15:29 jennifer asked Feb 23, 2020 at 15:23 jenniferjennifer 7625 silver badges17 bronze badges 1- Does this answer your question? Node.js - performance.now is not a function – UnholySheep Commented Feb 23, 2020 at 15:28
2 Answers
Reset to default 7It's part of the browser's javascript API, no 3rd party is needed.
From MDN https://developer.mozilla/en-US/docs/Web/API/Performance/now:
The returned value represents the time elapsed since the time origin.
Usage example:
const t0 = performance.now();
doSomething();
const t1 = performance.now();
console.log(`Call to doSomething took ${t1 - t0} milliseconds.`);
no installation it's part of the node api. Your best answer, by far, will be to look at the thorough documentation here - https://nodejs/api/perf_hooks.html.
本文标签: javascriptHow do I use performancenow()Stack Overflow
版权声明:本文标题:javascript - How do I use performance.now()? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743875530a2554255.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论