Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const performance = require('perf_hooks').performance;
- function checkout(n){
- var sum = 0;
- for(var i=0;i<n;i++){
- sum+=1;
- }
- return sum;
- }
- function apply(n){
- var time = performance.now();
- console.log(checkout(n));
- time = performance.now()- time;
- console.log('execution time = ', time);
- }
- for (let index = 0; index < 5; index++) {
- apply(10**6);
- }
- // => ~14-1 ms
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement