Skip to content

Instantly share code, notes, and snippets.

@Paxa
Created September 29, 2016 17:52
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 Paxa/6b3acf84d6daf0add8baa6659462dae7 to your computer and use it in GitHub Desktop.
Save Paxa/6b3acf84d6daf0add8baa6659462dae7 to your computer and use it in GitHub Desktop.
LightRecord benchmarks
% ruby --version
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
% ruby benchmark/comparing/native_vs_sequel_vs_lr.rb
Testing table already exists
Warming up --------------------------------------
Hash 1.000 i/100ms
Array 1.000 i/100ms
Sequel 1.000 i/100ms
ActiveRecord 1.000 i/100ms
LightRecord 1.000 i/100ms
LightRecord Stream 1.000 i/100ms
Calculating -------------------------------------
Hash 2.184 (± 0.0%) i/s - 22.000 in 10.109064s
Array 3.965 (± 0.0%) i/s - 40.000 in 10.180010s
Sequel 2.032 (± 0.0%) i/s - 21.000 in 10.436576s
ActiveRecord 1.030 (± 0.0%) i/s - 11.000 in 10.733970s
LightRecord 1.815 (± 0.0%) i/s - 18.000 in 10.185203s
LightRecord Stream 2.129 (± 0.0%) i/s - 22.000 in 10.418136s
Comparison:
Array: 4.0 i/s
Hash: 2.2 i/s - 1.82x slower
LightRecord Stream: 2.1 i/s - 1.86x slower
Sequel: 2.0 i/s - 1.95x slower
LightRecord: 1.8 i/s - 2.18x slower
ActiveRecord: 1.0 i/s - 3.85x slower
% LIMIT=2000 ruby benchmark/comparing/native_vs_sequel_vs_lr.rb
Testing table already exists
Warming up --------------------------------------
Hash 3.000 i/100ms
Array 6.000 i/100ms
Sequel 3.000 i/100ms
ActiveRecord 1.000 i/100ms
LightRecord 2.000 i/100ms
LightRecord Stream 3.000 i/100ms
Calculating -------------------------------------
Hash 38.809 (±12.9%) i/s - 384.000 in 10.024184s
Array 72.043 (± 5.6%) i/s - 720.000 in 10.027789s
Sequel 36.809 (± 8.2%) i/s - 366.000 in 10.009642s
ActiveRecord 18.983 (±10.5%) i/s - 188.000 in 10.015863s
LightRecord 30.256 (±16.5%) i/s - 296.000 in 10.047230s
LightRecord Stream 36.046 (±11.1%) i/s - 357.000 in 10.060780s
Comparison:
Array: 72.0 i/s
Hash: 38.8 i/s - 1.86x slower
Sequel: 36.8 i/s - 1.96x slower
LightRecord Stream: 36.0 i/s - 2.00x slower
LightRecord: 30.3 i/s - 2.38x slower
ActiveRecord: 19.0 i/s - 3.80x slower
% ruby benchmark/comparing/compare_memory.rb
Testing table already exists
Calculating -------------------------------------
Hash 58.911M memsize ( 1.208k retained)
512.888k objects ( 1.000 retained)
50.000 strings ( 0.000 retained)
Array 26.088M memsize ( 1.208k retained)
512.906k objects ( 1.000 retained)
50.000 strings ( 0.000 retained)
Sequel 60.381M memsize ( 1.352k retained)
549.540k objects ( 1.000 retained)
50.000 strings ( 0.000 retained)
ActiveRecord 90.523M memsize ( 8.712k retained)
847.653k objects ( 68.000 retained)
50.000 strings ( 12.000 retained)
LightRecord 63.659M memsize ( 26.672k retained)
623.329k objects ( 130.000 retained)
50.000 strings ( 1.000 retained)
LightRecord Stream 63.076M memsize ( 30.952k retained)
623.438k objects ( 158.000 retained)
50.000 strings ( 2.000 retained)
Comparison:
Array: 26087839 allocated
Hash: 58911183 allocated - 2.26x more
Sequel: 60380655 allocated - 2.31x more
LightRecord Stream: 63075648 allocated - 2.42x more
LightRecord: 63659010 allocated - 2.44x more
ActiveRecord: 90523268 allocated - 3.47x more
% ruby benchmark/comparing/attribute_reading.rb
Testing table already exists
Warming up --------------------------------------
Hash 1.000 i/100ms
Array 1.000 i/100ms
Sequel 1.000 i/100ms
ActiveRecord 1.000 i/100ms
LightRecord 1.000 i/100ms
LightRecord Stream 1.000 i/100ms
Calculating -------------------------------------
Hash 2.086 (± 0.0%) i/s - 21.000 in 10.111634s
Array 3.972 (± 0.0%) i/s - 40.000 in 10.087317s
Sequel 1.968 (± 0.0%) i/s - 20.000 in 10.214893s
ActiveRecord 0.645 (± 0.0%) i/s - 7.000 in 10.882003s
LightRecord 1.686 (± 0.0%) i/s - 17.000 in 10.314141s
LightRecord Stream 2.063 (± 0.0%) i/s - 21.000 in 10.256526s
Comparison:
Array: 4.0 i/s
Hash: 2.1 i/s - 1.90x slower
LightRecord Stream: 2.1 i/s - 1.93x slower
Sequel: 2.0 i/s - 2.02x slower
LightRecord: 1.7 i/s - 2.36x slower
ActiveRecord: 0.6 i/s - 6.15x slower
% ruby benchmark/comparing/attribute_reading.rb
Testing table already exists
Warming up --------------------------------------
Hash 1.000 i/100ms
Array 1.000 i/100ms
Sequel 1.000 i/100ms
ActiveRecord 1.000 i/100ms
LightRecord 1.000 i/100ms
LightRecord Stream 1.000 i/100ms
Calculating -------------------------------------
Hash 2.003 (± 0.0%) i/s - 20.000 in 10.099183s
Array 3.695 (± 0.0%) i/s - 37.000 in 10.122830s
Sequel 1.954 (± 0.0%) i/s - 20.000 in 10.299423s
ActiveRecord 0.642 (± 0.0%) i/s - 7.000 in 10.928174s
LightRecord 1.684 (± 0.0%) i/s - 17.000 in 10.313150s
LightRecord Stream 2.067 (± 0.0%) i/s - 21.000 in 10.242797s
Comparison:
Array: 3.7 i/s
LightRecord Stream: 2.1 i/s - 1.79x slower
Hash: 2.0 i/s - 1.84x slower
Sequel: 2.0 i/s - 1.89x slower
LightRecord: 1.7 i/s - 2.19x slower
ActiveRecord: 0.6 i/s - 5.75x slower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment