Skip to content

Instantly share code, notes, and snippets.

@tusharmath
Last active December 21, 2015 07:29
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 tusharmath/6271339 to your computer and use it in GitHub Desktop.
Save tusharmath/6271339 to your computer and use it in GitHub Desktop.
Working performance comparison between typed arrays and simple array
operatorInt = (count, items) ->
i=0
start = (new Date).getTime()
while(i++ != count)
items[0] = 1000
return (new Date).getTime() - start
operatorSimple = (count, items) ->
i=0
start = (new Date).getTime()
while(i++ != count)
items[0] = 1000
return (new Date).getTime() - start
times = 1000 #* 1000
simple = 0
typed = 0
while(times-- != 0)
size = 1000*1000
arrSize = size
simpleArray = new Array arrSize
uArray = new Uint8Array arrSize
intArray = new Int8Array arrSize
simple += operatorSimple(size, simpleArray)
typed += operatorInt(size, intArray)
console.log(times) if(times%100 is 0)
console.log('Simple:', simple)
console.log('Typed:', typed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment