Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Nov 11, 2023
1 parent b5cff4b commit d5e84e7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
17 changes: 14 additions & 3 deletions example/benchmark_insert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def run_execute(x)
end

def run_execute_async(x)
futures = []

x.report('cassandra-driver:execute_async') do
future = @session.execute_async(
statement,
Expand All @@ -67,7 +69,11 @@ def run_execute_async(x)
)
future.on_success do |rows|
end

futures << future
end

Cassandra::Future.all(*futures).get
end

def statement
Expand Down Expand Up @@ -96,6 +102,8 @@ def run_execute(x)
end

def run_execute_async(x)
futures = []

x.report('ilios:execute_async') do
statement.bind(
{
Expand All @@ -106,10 +114,12 @@ def run_execute_async(x)
)
future = Ilios::Cassandra.session.execute_async(statement)
future.on_success do |results|
results.each do |row|
end
end

futures << future
end

futures.each(&:await)
end

def statement
Expand All @@ -128,7 +138,8 @@ def statement
BenchmarkCassandra.new.run_execute_async(x)
end

sleep 10
GC.start
sleep 20

puts ''
Benchmark.ips do |x|
Expand Down
15 changes: 14 additions & 1 deletion example/benchmark_select.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ def run_execute(x)
end

def run_execute_async(x)
futures = []

x.report('cassandra-driver:execute_async') do
future = @session.execute_async(statement)
future.on_success do |rows|
end

futures << future
end

Cassandra::Future.all(*futures).get
end

def statement
Expand All @@ -87,13 +93,19 @@ def run_execute(x)
end

def run_execute_async(x)
futures = []

x.report('ilios:execute_async') do
future = Ilios::Cassandra.session.execute_async(statement)
future.on_success do |results|
results.each do |row|
end
end

futures << future
end

futures.each(&:await)
end

def statement
Expand All @@ -108,7 +120,8 @@ def statement
BenchmarkCassandra.new.run_execute_async(x)
end

sleep 10
GC.start
sleep 20

puts ''
Benchmark.ips do |x|
Expand Down

0 comments on commit d5e84e7

Please sign in to comment.