Skip to content

Commit

Permalink
Update benchmark codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Mar 7, 2024
1 parent 023fe82 commit c308713
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 34 deletions.
37 changes: 20 additions & 17 deletions example/benchmark_insert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
source 'https://rubygems.org'
gem 'benchmark-ips'
gem 'sorted_set'
gem 'bigdecimal'
gem 'cassandra-driver', require: 'cassandra'
gem 'ilios'
end
Expand Down Expand Up @@ -79,6 +80,11 @@ def run_execute_async(x)
end

futures << future

if futures.size > 100
tmp = futures.slice!(0..10)
Cassandra::Future.all(*tmp).get
end
end

Cassandra::Future.all(*futures).get
Expand Down Expand Up @@ -125,6 +131,10 @@ def run_execute_async(x)
end

futures << future

if futures.size > 100

Check failure on line 135 in example/benchmark_insert.rb

View workflow job for this annotation

GitHub Actions / RuboCop

[Correctable] Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
futures.slice!(0..10).each(&:await)
end
end

futures.each(&:await)
Expand All @@ -142,8 +152,8 @@ def statement
end

Benchmark.ips do |x|
x.warmup = 1
x.time = 2
x.warmup = 0
x.time = 10
BenchmarkCassandra.new.run_execute(x)
BenchmarkCassandra.new.run_execute_async(x)
end
Expand All @@ -153,35 +163,28 @@ def statement

puts ''
Benchmark.ips do |x|
x.warmup = 1
x.time = 2
x.warmup = 0
x.time = 10
BenchmarkIlios.new.run_execute(x)
BenchmarkIlios.new.run_execute_async(x)
end

=begin
## Environment
- OS: Manjaro Linux x86_64
- Kernel: 6.7.7-1-MANJARO
- CPU: AMD Ryzen 9 7940HS
- Compiler: gcc 13.2.1
- Ruby: ruby 3.2.2
- Ruby: ruby 3.3.0
## Results
Warming up --------------------------------------
cassandra-driver:execute
335.000 i/100ms
cassandra-driver:execute_async
2.558k i/100ms
Calculating -------------------------------------
cassandra-driver:execute
3.154k34.1%) i/s - 3.685k in 2.036576s
4.121k19.4%) i/s - 39.035k in 9.979254s
cassandra-driver:execute_async
34.718k29.2%) i/s - 61.392k in 2.055368s
18.461k20.5%) i/s - 132.226k in 9.951913s
Warming up --------------------------------------
ilios:execute 439.000 i/100ms
ilios:execute_async 11.018k i/100ms
Calculating -------------------------------------
ilios:execute 4.393k 3.7%) i/s - 9.219k in 2.101254s
ilios:execute_async 138.471k38.3%) i/s - 242.396k in 2.101860s
ilios:execute 4.880k23.8%) i/s - 45.928k in 9.978697s
ilios:execute_async 348.102k53.6%) i/s - 966.952k in 9.745057s
=end
37 changes: 20 additions & 17 deletions example/benchmark_select.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
source 'https://rubygems.org'
gem 'benchmark-ips'
gem 'sorted_set'
gem 'bigdecimal'
gem 'cassandra-driver', require: 'cassandra'
gem 'ilios'
end
Expand Down Expand Up @@ -81,6 +82,11 @@ def run_execute_async(x)
end

futures << future

if futures.size > 100
tmp = futures.slice!(0..10)
Cassandra::Future.all(*tmp).get
end
end

Cassandra::Future.all(*futures).get
Expand Down Expand Up @@ -111,6 +117,10 @@ def run_execute_async(x)
end

futures << future

if futures.size > 100

Check failure on line 121 in example/benchmark_select.rb

View workflow job for this annotation

GitHub Actions / RuboCop

[Correctable] Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
futures.slice!(0..10).each(&:await)
end
end

futures.each(&:await)
Expand All @@ -124,8 +134,8 @@ def statement
end

Benchmark.ips do |x|
x.warmup = 1
x.time = 2
x.warmup = 0
x.time = 10
BenchmarkCassandra.new.run_execute(x)
BenchmarkCassandra.new.run_execute_async(x)
end
Expand All @@ -135,35 +145,28 @@ def statement

puts ''
Benchmark.ips do |x|
x.warmup = 1
x.time = 2
x.warmup = 0
x.time = 10
BenchmarkIlios.new.run_execute(x)
BenchmarkIlios.new.run_execute_async(x)
end

=begin
## Environment
- OS: Manjaro Linux x86_64
- Kernel: 6.7.7-1-MANJARO
- CPU: AMD Ryzen 9 7940HS
- Compiler: gcc 13.2.1
- Ruby: ruby 3.2.2
- Ruby: ruby 3.3.0
## Results
Warming up --------------------------------------
cassandra-driver:execute
12.000 i/100ms
cassandra-driver:execute_async
6.325k i/100ms
Calculating -------------------------------------
cassandra-driver:execute
50.608 (±23.7%) i/s - 96.000 in 2.024429s
139.571 (± 7.2%) i/s - 1.387k in 9.998314s
cassandra-driver:execute_async
68.923k34.7%) i/s - 107.525k in 2.031277s
11.554k86.6%) i/s - 2.467k in 10.001188s
Warming up --------------------------------------
ilios:execute 29.000 i/100ms
ilios:execute_async 24.554k i/100ms
Calculating -------------------------------------
ilios:execute 323.909 (± 7.1%) i/s - 667.000 in 2.068322s
ilios:execute_async 322.653k48.2%) i/s - 319.202k in 2.069078s
ilios:execute 327.715 (±16.5%) i/s - 3.187k in 9.994403s
ilios:execute_async 454.625k78.4%) i/s - 10.161k in 9.996146s
=end

0 comments on commit c308713

Please sign in to comment.