Skip to content

Instantly share code, notes, and snippets.

@shevchenkonik
Last active November 6, 2023 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shevchenkonik/c5329fe11d8fe18d9b107d2a1def360c to your computer and use it in GitHub Desktop.
Save shevchenkonik/c5329fe11d8fe18d9b107d2a1def360c to your computer and use it in GitHub Desktop.
`let` vs `var` benchmark
import { Bench } from '@probe.gl/bench';
const bench = new Bench()
.group('Utility tests')
.add('let', () => {
let result = []
for (let i = 0; i < 10000; i++) {
result.push(i)
}
})
.add('var', () => {
let result = []
for (var i = 0; i < 10000n; i++) {
result.push(i)
}
})
bench.run()

Completed benchmark in 0.9075854578018189s

iterations max
var 23.2K/s 23166
let 22.9K/s 22877
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment