The console provides a timer function, which can easily test the time-consuming code.
console.time(tag) and console.timeEnd(tag)
- They appear in pairs, and the tag is a string. When calling timeEnd, the tag string and time-consuming time will be appended;
- Between console.time(tag) and console.timeEnd(tag) is the time-consuming operation of the test code.
use
console.time("test")
for (var i = 0; i < 5; i++)
console.log(i)
console.timeEnd("test")
output
qml: 0
qml: 1
qml: 2
qml: 3
qml: 4
test: 91ms