For example, we tried to test this piece of code execution speed, we usually do:

For example, we tried to test this piece of code execution speed, we usually do:

 

 

However, given the current devices and browser run faster and faster, this test method code to run a fixed number of great conceptual difference will be the result of a time 0ms, apparently 0 is meaningless, as shown below

 

 

It is recommended to use benchmark.js code segment benchmark, while using jsPerf to share our benchmark tests

 

Benchmark.js use:

github address: https: //github.com/bestiejs/benchmark.js

 

Here we use benchmark.js to conduct performance testing two code segments, this is mainly to test the performance and join the concat:

 

Look at the results of the output:

 

Wherein, Ops / sec frequency and test results (Ops / sec) execute the test code is displayed per second, the larger is better. In addition to this result, and it will display the statistical error in the testing process, and a relatively slow best how much (%)

Clearly, here is the implementation of the performance will be better than join concat

 

Here we use jsPerf test this piece of code, implementation of the results is very much the same:

 

 

 

Links on sections of the test case is: https: //jsperf.com/kameleon-test2

jsPerf the link: https: //jsperf.com/

description link: https: //blog.csdn.net/kameleon2013/article/details/53394775

 

Guess you like

Origin www.cnblogs.com/cangqinglang/p/11416270.html