Skip to content

Benchmark

Kenichi Kamiya edited this page Mar 7, 2023 · 12 revisions

How to run benchmarks for this gem's features

There is some benchmarks

$ rake --tasks | grep 'benchmark'
rake benchmark/core_instance_methods.rb   # Rough benchmark for core_instance_methods.rb
rake benchmark/extra_instance_methods.rb  # Rough benchmark for extra_instance_methods.rb
rake benchmark/generators.rb              # Rough benchmark for generators.rb
rake benchmark/sample.rb                  # Rough benchmark for sample.rb
rake benchmark/sort.rb                    # Rough benchmark for sort.rb
rake benchmark_with_other_gems            # Compare generating String performance with other gems

How to compare with other gem's performance

This runs rough benchmarks

$ rake benchmark_with_other_gems
(Do not use `bundle exec`!)

See #213, 215 and 217 for further detail

Below is a snapshot results on 2023-03-08 with 0.8.0.pre

❯ rake benchmark_with_other_gems
------------------------------------------------------------------------
#### kachick - ruby-ulid(This one)
cd ./benchmark/compare_with_othergems/kachick
bundle install --quiet
bundle exec ruby -v ./generate.rb
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
Warming up --------------------------------------
         ULID.encode    24.073k i/100ms
Calculating -------------------------------------
         ULID.encode    237.226k (± 6.2%) i/s -      1.204M in   5.094403s
bundle exec ruby -v ./parser.rb
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
Warming up --------------------------------------
    ULID.decode_time    24.661k i/100ms
Calculating -------------------------------------
    ULID.decode_time    253.593k (± 4.3%) i/s -      1.282M in   5.066831s
cd -
------------------------------------------------------------------------
#### rafaelsales - ulid
cd ./benchmark/compare_with_othergems/rafaelsales
bundle install --quiet
bundle exec ruby -v ./generate.rb
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
Warming up --------------------------------------
       ULID.generate    12.764k i/100ms
Calculating -------------------------------------
       ULID.generate    125.398k (± 4.4%) i/s -    638.200k in   5.100201s
bundle exec ruby -v ./parser.rb
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
"`ulid gem - 1.4.0` does not have parsers yet"
cd -
------------------------------------------------------------------------
#### abachman - ulid-ruby
cd ./benchmark/compare_with_othergems/abachman
bundle install --quiet
bundle exec ruby -v ./generate.rb
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
Warming up --------------------------------------
       ULID.generate    11.513k i/100ms
Calculating -------------------------------------
       ULID.generate    114.931k (± 4.5%) i/s -    575.650k in   5.019902s
bundle exec ruby -v ./parser.rb
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
Warming up --------------------------------------
           ULID.time     8.594k i/100ms
Calculating -------------------------------------
           ULID.time     80.736k (± 5.4%) i/s -    403.918k in   5.018672s
cd -
irb(main):002:0> Rational(237.226, 125.398).to_f
=> 1.8917845579674317
irb(main):003:0> Rational(237.226, 114.931).to_f
=> 2.0640732265446227
irb(main):004:0> Rational(253.593, 80.736).to_f
=> 3.141015160523186

This project does not prioritize on the speed. However it actually works faster than others! ⚡⚡

Clone this wiki locally