F1 is x times faster than F2
|
|
Great script, very useful. One thing I would change: instead of giving you the difference in ms, how about as a multiple? eg. if F1: 200ms
Instead of "F2 is 100ms faster than F1" how about "F2 is 2.0 times faster than F1" |
|
|
A good idea but I like to have the exact ms. I also added the execution times of the functions in the alert box. |
|
|
Well, the reason I suggest this is that whether you run it with 1m loops or 50m loops, the multiple/ratio between the two functions [should] stay (about) the same, providing the true relationship between the two functions. Yet the actual difference in ms between them will vary wildly (say, by *50). If anybody wants to implement this themselves, just change the end to something like: if(time_measure_1 < time_measure_2)
alert("F1 is " + (time_measure_2 / time_measure_1).toFixed(2) + "x faster than F2");
else
alert("F2 is " + (time_measure_1 / time_measure_2).toFixed(2) + "x faster than F1");
|
|
|
Yeah. I do like the idea but I have to have the times in ms there too. Maybe I can add the ratio as another line on the alert box.
|