Skip to content

Commit

Permalink
Update benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
GarrisonJ committed Apr 26, 2024
1 parent 969fea0 commit 4df8afe
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 116 deletions.
Binary file modified benchmark/add_performance_comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions benchmark/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

# Benchmarking original SortedSet
bm.report("SortedSet #{n}:") do
total_time = {add: 0, include: 0, loop: 0, delete: 0}
total_time = {initialize: 0, add: 0, include: 0, loop: 0, delete: 0}
runs.times do
sorted_set = SortedSet.new
total_time[:initialize] += Benchmark.measure { SortedSet.new(list_adds) }.real
total_time[:add] += Benchmark.measure { list_adds.each { |i| sorted_set.add(i) } }.real
total_time[:include] += Benchmark.measure { (1..n).map { rand((-0.5*n).to_i..(n*1.5).to_i) }.each { |i| sorted_set.include?(i) } }.real
total_time[:loop] += Benchmark.measure { sorted_set.each { |i| } }.real
Expand All @@ -31,6 +32,7 @@
end
end.real
end
results_for_n[:initialize_sorted_set] = total_time[:initialize] / runs
results_for_n[:add_sorted_set] = total_time[:add] / runs
results_for_n[:include_sorted_set] = total_time[:include] / runs
results_for_n[:loop_sorted_set] = total_time[:loop] / runs
Expand All @@ -39,9 +41,10 @@

# Benchmarking custom SortedSet
bm.report("SortedContainers #{n}:") do
total_time = {add: 0, include: 0, loop: 0, delete: 0}
total_time = {initialize: 0, add: 0, include: 0, loop: 0, delete: 0}
runs.times do
sorted_set = SortedContainers::SortedSet.new
total_time[:initialize] += Benchmark.measure { SortedContainers::SortedSet.new(list_adds) }.real
total_time[:add] += Benchmark.measure { list_adds.each { |i| sorted_set.add(i) } }.real
total_time[:include] += Benchmark.measure { (1..n).map { rand((-0.5*n).to_i..(n*1.5).to_i) }.each { |i| sorted_set.include?(i) } }.real
total_time[:loop] += Benchmark.measure { sorted_set.each { |i| } }.real
Expand All @@ -51,6 +54,7 @@
end
end.real
end
results_for_n[:initialize_sorted_containers] = total_time[:initialize] / runs
results_for_n[:add_sorted_containers] = total_time[:add] / runs
results_for_n[:include_sorted_containers] = total_time[:include] / runs
results_for_n[:loop_sorted_containers] = total_time[:loop] / runs
Expand Down
46 changes: 0 additions & 46 deletions benchmark/benchmark_init_only.rb

This file was deleted.

12 changes: 6 additions & 6 deletions benchmark/benchmark_results.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
size,add_sorted_set,include_sorted_set,loop_sorted_set,delete_sorted_set,add_sorted_containers,include_sorted_containers,loop_sorted_containers,delete_sorted_containers
1000000,1.2325135999359191,11.639327200129628,0.14237359995022417,1.3688056000508368,1.564646599907428,0.6316141999326647,0.044612800050526855,1.8568651999346912
2000000,3.1588088000193237,42.194053599890324,0.3135467999614775,3.3180113999173044,3.7178223999217153,1.5509135999716819,0.08306660009548068,4.205694200005382
3000000,5.286830999981612,95.30711920000613,0.47653339989483356,5.443703200109303,6.175909599941224,2.700068200007081,0.11789239989593625,6.770565199945122
4000000,7.538741199858487,153.70711900005116,0.6546002000570297,7.559051800053567,8.882256799936295,4.182955399993807,0.1547184000723064,9.676217600051313
5000000,10.20743679990992,241.74679239979014,0.8260514000430703,9.85318099996075,11.755913200229406,5.6500453999266025,0.18556239986792206,12.258404000196606
size,initialize_sorted_set,add_sorted_set,include_sorted_set,loop_sorted_set,delete_sorted_set,initialize_sorted_containers,add_sorted_containers,include_sorted_containers,loop_sorted_containers,delete_sorted_containers
1000000,1.224537000246346,1.3319036000408233,11.751401599962264,0.1402883999980986,1.3348814000375568,0.4023770001716912,1.5611974000930786,0.6331466001458466,0.04364499999210238,1.8914303999394178
2000000,2.99586120005697,3.4789291999302803,43.044228199962525,0.3109924000687897,3.1296502000652255,0.9056976000778377,3.781497000064701,1.4786425999365747,0.08165540006011725,4.254382199980318
3000000,5.124303399864584,6.239440600015223,85.73076480003074,0.47364640003070235,5.336848200112581,1.5066193998791277,6.235969400033355,2.5797877999953926,0.1289702001027763,6.770450200047344
4000000,7.4429126000963155,8.575669200252742,153.32299140002578,0.6475916000083088,7.508836399950087,2.0407237999141215,8.872534200083464,3.9519795999862253,0.14986819997429848,9.702906599920244
5000000,10.792367999907583,12.09743200019002,241.63080279994756,0.8215247998945415,9.775965599901975,2.8635928000323476,11.81594120003283,5.384774999972433,0.18414179980754852,12.333123400155454
6 changes: 0 additions & 6 deletions benchmark/benchmark_results_init.csv

This file was deleted.

3 changes: 2 additions & 1 deletion benchmark/build_graphs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Prepare data arrays
sizes = data["size"]
operations = {
"initialize" => %w[initialize_sorted_set initialize_sorted_containers],
"add" => %w[add_sorted_set add_sorted_containers],
"include" => %w[include_sorted_set include_sorted_containers],
"iteration" => %w[loop_sorted_set loop_sorted_containers],
Expand All @@ -31,7 +32,7 @@ def create_graph(title, _sizes, data1, data2, labels, file_name)
g.data("SortedContainers::SortedSet", data2)

# X-axis labels
g.x_axis_label = "Number of operations"
g.x_axis_label = "Number of operations/elements"

# Labels for x_axis
g.labels = labels
Expand Down
55 changes: 0 additions & 55 deletions benchmark/build_graphs_init_only.rb

This file was deleted.

Binary file modified benchmark/delete_performance_comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified benchmark/include_performance_comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed benchmark/init_performance_comparison.png
Binary file not shown.
Binary file modified benchmark/initialize_performance_comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed benchmark/initiation_performance_comparison.png
Binary file not shown.
Binary file modified benchmark/iteration_performance_comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4df8afe

Please sign in to comment.