I ran the same test for 4 rounds for 3 methods for 50,000,000 times each.
Using let
Using anonymous function (This is my method in this article)
Using dictionary (Object - Mohammed's idea)
At the first round, let is much faster than others. But at round 2, 3 and 4, the runtime of let was much different than the round 1. I think the first round may be including certain initial condition (I do not know the details though). Let's see the last 3 rounds.
Round 1
Using let: 55.4 ms
Using anonymous fun: 317.1 ms
Using dictionary: 516.4 ms
Round 2
Using anonymous fun: 320.3 ms
Using dictionary: 520.3 ms
Using let: 312.7 ms
Round 3
Using dictionary: 516.1 ms
Using let: 315.3 ms
Using anonymous fun: 328.3 ms
Round 4
Using let: 317.9 ms
Using anonymous fun: 329.7 ms
Using dictionary: 522.3 ms
let and anonymous fun does not have much difference but dictionary is a bit slower than others. I guess the cause is that the speed of accessing a dictionary is slower than value comparison (--> switch).
I got an interesting result.
I ran the same test for 4 rounds for 3 methods for 50,000,000 times each.
At the first round,
let
is much faster than others. But at round 2, 3 and 4, the runtime oflet
was much different than the round 1. I think the first round may be including certain initial condition (I do not know the details though). Let's see the last 3 rounds.This is my code.
let
andanonymous fun
does not have much difference butdictionary
is a bit slower than others. I guess the cause is that the speed of accessing a dictionary is slower thanvalue comparison (--> switch)
.I thought dictionary faster than others