Skip to content

Commit 25312ad

Browse files
authored
Check how long an operation takes
1 parent 8980e66 commit 25312ad

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,13 @@ Array(6).join('👽')
9393
//👽👽👽👽👽👽
9494

9595
```
96+
# Check how long an operation takes
97+
```javascript
98+
//The performance.now() method returns a DOMHighResTimeStamp, measured in milliseconds.
99+
//performance.now() is relative to page load and more precise in orders of magnitude. Use cases include benchmarking and other cases where a high-resolution time is required such as media (gaming, audio, video, etc.)
100+
101+
var startTime = performance.now();
102+
doSomething();
103+
const endTime = performance.now();
104+
console.log("this doSomething took " + (endTime - startTime) + " milliseconds.");
105+
```

0 commit comments

Comments
 (0)