Skip to content

Instantly share code, notes, and snippets.

@Chadtech
Created February 7, 2015 21:08
Show Gist options
  • Save Chadtech/387387b003ecc6d08d29 to your computer and use it in GitHub Desktop.
Save Chadtech/387387b003ecc6d08d29 to your computer and use it in GitHub Desktop.
_ = require 'lodash'
A = [ '0', '1', '2', '3' ]
B = [ '4', '5', '6', '7' ]
C = [ '8', '9', 'a', 'b' ]
D = [ 'c', 'd', 'e', 'f' ]
hueg = 12
huegIndex = 0
while huegIndex < hueg
A = A.concat A
B = B.concat B
C = C.concat C
D = D.concat D
huegIndex++
chunks = [ A, B, C, D ]
huegIndex = 0
while huegIndex < 4
chunks = chunks.concat chunks
huegIndex++
###########
# PROCESS 0
###########
start = Date.now()
content0 = _.reduce chunks, (memo, chunk) ->
memo.concat chunk
duration = Date.now() - start
console.log 'PROCESS 0 DURATION', duration
###########
# PROCESS 1
###########
start = Date.now()
content1 = []
_.forEach chunks, (chunk) ->
_.forEach chunk, (datum) ->
content1.push datum
duration = Date.now() - start
console.log 'PROCESS 1 DURATION', duration
###########
# PROCESS 2
###########
start = Date.now()
content2 = _.flatten chunks
duration = Date.now() - start
console.log 'PROCESS 2 DURATION', duration
###
Ct:ctDopna04YFE Chadtech$ coffee flattenTest.coffee
PROCESS 0 DURATION 853
PROCESS 1 DURATION 109
PROCESS 2 DURATION 115
Ct:ctDopna04YFE Chadtech$ coffee flattenTest.coffee
PROCESS 0 DURATION 842
PROCESS 1 DURATION 100
PROCESS 2 DURATION 116
Ct:ctDopna04YFE Chadtech$ coffee flattenTest.coffee
PROCESS 0 DURATION 855
PROCESS 1 DURATION 104
PROCESS 2 DURATION 117
###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment