Skip to content

Instantly share code, notes, and snippets.

@2called-chaos
Last active November 23, 2015 17:50
Show Gist options
  • Save 2called-chaos/a0ea619fdc7ef245719d to your computer and use it in GitHub Desktop.
Save 2called-chaos/a0ea619fdc7ef245719d to your computer and use it in GitHub Desktop.
Usernamegen benchmarks
initial load 0.010000 0.000000 0.010000 ( 0.001589)
Calculating -------------------------------------
::new 71.000 i/100ms
-------------------------------------------------
::new 726.286 (± 3.4%) i/s - 3.692k
Calculating -------------------------------------
::one 71.000 i/100ms
#one 6.942k i/100ms
-------------------------------------------------
::one 697.537 (± 5.6%) i/s - 3.479k
#one 84.734k (± 4.2%) i/s - 423.462k
Comparison:
#one: 84733.8 i/s
::one: 697.5 i/s - 121.48x slower
Calculating -------------------------------------
#one 6.792k i/100ms
#some(1) 6.469k i/100ms
#some(10) 787.000 i/100ms
#all 1.000 i/100ms
#all_for_thing 7.000 i/100ms
#all_for_desc 10.000 i/100ms
-------------------------------------------------
#one 85.050k (± 7.4%) i/s - 427.896k
#some(1) 77.483k (± 5.4%) i/s - 388.140k
#some(10) 8.197k (± 5.0%) i/s - 40.924k
#all 0.066 (± 0.0%) i/s - 1.000 in 15.148152s
#all_for_thing 80.428 (±19.9%) i/s - 378.000
#all_for_desc 104.230 (± 6.7%) i/s - 520.000
Comparison:
#one: 85050.1 i/s
#some(1): 77483.0 i/s - 1.10x slower
#some(10): 8197.1 i/s - 10.38x slower
#all_for_desc: 104.2 i/s - 815.98x slower
#all_for_thing: 80.4 i/s - 1057.47x slower
#all: 0.1 i/s - 1288351.46x slower
Benchmark.benchmark("", 20) do |x|
x.report("cold 1") { 1.times{ Usernamegen.new.one } }
x.report("cold 100") { 100.times{ Usernamegen.new.one } }
x.report("cold 100_000") { 100_000.times{ Usernamegen.new.one } }
instance = Usernamegen.new
x.report("warm 1") { 1.times{ instance.one } }
x.report("warm 100") { 100.times{ instance.one } }
x.report("warm 100_000") { 100_000.times{ instance.one } }
end
# cold 1 0.000000 0.000000 0.000000 ( 0.002208)
# cold 100 0.150000 0.010000 0.160000 ( 0.146431)
# cold 100_000 135.820000 1.770000 137.590000 (137.603294)
# warm 1 0.000000 0.000000 0.000000 ( 0.000023)
# warm 100 0.000000 0.000000 0.000000 ( 0.001111)
# warm 100_000 1.240000 0.010000 1.250000 ( 1.253366)
Calculating -------------------------------------
#one 6.593k i/100ms
#some(1) 6.072k i/100ms
#some(10) 754.000 i/100ms
-------------------------------------------------
#one 81.080k (± 2.6%) i/s - 408.766k
#some(1) 75.689k (± 2.5%) i/s - 382.536k
#some(10) 7.862k (± 3.0%) i/s - 39.962k
Comparison:
#one: 81080.4 i/s
#some(1): 75689.1 i/s - 1.07x slower
#some(10): 7862.0 i/s - 10.31x slower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment