Skip to content

Instantly share code, notes, and snippets.

@bobrik
Created July 11, 2012 10:06
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 bobrik/3089415 to your computer and use it in GitHub Desktop.
Save bobrik/3089415 to your computer and use it in GitHub Desktop.
new lodash difference method benchmark
# this is .difference method implementation performance test with different array sizes
# new method marked as "Objects"
# if you have arrays with 100s of elements - this is fast as hell compared with original .difference
# for 10k elements in arrays it is 200X faster (sic!)
# if you have more elements - this may your only hope: 100k is 350X faster
# so here are results from my apple macbook air late 2011 from latest master
=== testing simple ===
array sizes: 0 4 2
lodash is equal to underscore: true
lodash is equal to object method: true
difference size: 0
Lo-Dash x 5,225,665 ops/sec ±1.84% (96 runs sampled)
Underscore x 270,810 ops/sec ±2.57% (86 runs sampled)
Objects x 459,016 ops/sec ±1.90% (94 runs sampled)
Fastest is Lo-Dash
=== testing 10 ===
array sizes: 10 10 10
lodash is equal to underscore: true
lodash is equal to object method: true
difference size: 6
Lo-Dash x 1,061,009 ops/sec ±1.91% (94 runs sampled)
Underscore x 133,375 ops/sec ±2.79% (87 runs sampled)
Objects x 260,654 ops/sec ±2.58% (90 runs sampled)
Fastest is Lo-Dash
=== testing 100 ===
array sizes: 100 100 100
lodash is equal to underscore: true
lodash is equal to object method: true
difference size: 37
Lo-Dash x 25,198 ops/sec ±1.12% (96 runs sampled)
Underscore x 18,787 ops/sec ±1.28% (97 runs sampled)
Objects x 68,638 ops/sec ±1.49% (96 runs sampled)
Fastest is Objects
=== testing 1k ===
array sizes: 1000 1000 1000
lodash is equal to underscore: true
lodash is equal to object method: true
difference size: 818
Lo-Dash x 197 ops/sec ±0.90% (94 runs sampled)
Underscore x 212 ops/sec ±1.78% (93 runs sampled)
Objects x 1,301 ops/sec ±1.47% (88 runs sampled)
Fastest is Objects
=== testing 10k ===
array sizes: 10000 10000 10000
lodash is equal to underscore: true
lodash is equal to object method: true
difference size: 1310
Lo-Dash x 3.64 ops/sec ±2.71% (21 runs sampled)
Underscore x 4.16 ops/sec ±4.88% (26 runs sampled)
Objects x 700 ops/sec ±1.78% (92 runs sampled)
Fastest is Objects
=== testing 100k ===
array sizes: 100000 100000 100000
lodash is equal to underscore: true
lodash is equal to object method: true
difference size: 51517
Lo-Dash x 0.02 ops/sec ±0.60% (5 runs sampled)
Underscore x 0.03 ops/sec ±3.68% (5 runs sampled)
Objects x 6.99 ops/sec ±85.37% (78 runs sampled)
Fastest is Objects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment