Test case name | Result |
---|---|
Math.random().toString(36).slice(-5) | |
(+new Date).toString(36).slice(-5) | |
btoa(Math.random()).slice(0, 5) | |
btoa(+new Date).slice(-7, -2) | |
btoa(+new Date).substr(-7, 5) |
Test name | Executions per second |
---|---|
Math.random().toString(36).slice(-5) | 3315275.0 Ops/sec |
(+new Date).toString(36).slice(-5) | 1857315.0 Ops/sec |
btoa(Math.random()).slice(0, 5) | 1069847.0 Ops/sec |
btoa(+new Date).slice(-7, -2) | 2213181.0 Ops/sec |
btoa(+new Date).substr(-7, 5) | 2247551.0 Ops/sec |