d_heap 0.1.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -1,14 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
6
12
  require "rake/extensiontask"
7
13
 
8
- task :build => :compile
14
+ task build: :compile
9
15
 
10
16
  Rake::ExtensionTask.new("d_heap") do |ext|
11
17
  ext.lib_dir = "lib/d_heap"
12
18
  end
13
19
 
14
- task :default => [:clobber, :compile, :spec]
20
+ task default: %i[clobber compile spec rubocop]
@@ -0,0 +1,28 @@
1
+ ---
2
+ prelude: |
3
+ system("#{RbConfig.ruby} bin/rake compile", err: :out, exception: true)
4
+ require "d_heap/benchmarks"
5
+ include DHeap::Benchmarks
6
+ fill_random_vals
7
+
8
+ n = ENV.fetch("BENCH_N", 1000).to_i
9
+
10
+ benchmark:
11
+ - script: &script |
12
+ q.clear
13
+ i = 0
14
+ while i < n
15
+ q << random_val
16
+ i += 1
17
+ end
18
+ # name: "push N (findmin)"
19
+ # prelude: "q = initq FindMin"
20
+ # - script: *script
21
+ name: "push N (bsearch)"
22
+ prelude: "q = initq BSearch"
23
+ - script: *script
24
+ name: "push N (rb_heap)"
25
+ prelude: "q = initq RbHeap"
26
+ - script: *script
27
+ name: "push N (c_dheap)"
28
+ prelude: "q = initq DHeap"
@@ -0,0 +1,31 @@
1
+ ---
2
+ prelude: |
3
+ system("#{RbConfig.ruby} bin/rake compile", err: :out, exception: true)
4
+ require "d_heap/benchmarks"
5
+ include DHeap::Benchmarks
6
+ fill_random_vals
7
+
8
+ n = ENV.fetch("BENCH_N", 1000).to_i
9
+ i = 0
10
+
11
+ benchmark:
12
+ - script: &script |
13
+ while i < n
14
+ q << random_val
15
+ i += 1
16
+ end
17
+ while 0 < i
18
+ q.pop
19
+ i -= 1
20
+ end
21
+ name: "push N + pop N (findmin)"
22
+ prelude: "q = initq FindMin"
23
+ - script: *script
24
+ name: "push N + pop N (bsearch)"
25
+ prelude: "q = initq BSearch"
26
+ - script: *script
27
+ name: "push N + pop N (rb_heap)"
28
+ prelude: "q = initq RbHeap"
29
+ - script: *script
30
+ name: "push N + pop N (c_dheap)"
31
+ prelude: "q = initq DHeap"
@@ -0,0 +1,24 @@
1
+ ---
2
+ prelude: |
3
+ system("#{RbConfig.ruby} bin/rake compile", err: :out, exception: true)
4
+ require "d_heap/benchmarks"
5
+ include DHeap::Benchmarks
6
+ fill_random_vals
7
+
8
+ n = ENV.fetch("BENCH_N", 1000).to_i
9
+
10
+ benchmark:
11
+ - script: &script |
12
+ q << random_val
13
+ q.pop
14
+ name: "push + pop (findmin)"
15
+ prelude: "q = initq FindMin, n"
16
+ - script: *script
17
+ name: "push + pop (bsearch)"
18
+ prelude: "q = initq BSearch, n"
19
+ - script: *script
20
+ name: "push + pop (rb_heap)"
21
+ prelude: "q = initq RbHeap, n"
22
+ - script: *script
23
+ name: "push + pop (c_dheap)"
24
+ prelude: "q = initq DHeap, n"
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+ set -eu
3
+
4
+ export BENCH_N="$1"
5
+ shift
6
+
7
+ exec ruby "$@"
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'benchmark-driver' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("benchmark_driver", "benchmark-driver")
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "pathname"
5
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
6
+ require "rubygems"
7
+ require "bundler/setup"
8
+
9
+ require "d_heap/benchmarks/benchmarker"
10
+ DHeap::Benchmarks::Benchmarker.new.call
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "bundler/setup"
4
5
  require "d_heap"
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "pathname"
5
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
6
+ require "rubygems"
7
+ require "bundler/setup"
8
+
9
+ require "d_heap/benchmarks/profiler"
10
+ DHeap::Benchmarks::Profiler.new.call
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rubocop", "rubocop")
@@ -1,4 +1,6 @@
1
- require_relative 'lib/d_heap/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/d_heap/version"
2
4
 
3
5
  Gem::Specification.new do |spec|
4
6
  spec.name = "d_heap"
@@ -6,7 +8,7 @@ Gem::Specification.new do |spec|
6
8
  spec.authors = ["nicholas a. evans"]
7
9
  spec.email = ["nicholas.evans@gmail.com"]
8
10
 
9
- spec.summary = %q{A d-ary heap implementation, for priority queues}
11
+ spec.summary = "A d-ary heap implementation, for priority queues"
10
12
  spec.description = <<~DESC
11
13
  A C extension implementation of a d-ary heap data structure, suitable for
12
14
  use in e.g. priority queues or Djikstra's algorithm.
@@ -21,11 +23,14 @@ Gem::Specification.new do |spec|
21
23
 
22
24
  # Specify which files should be added to the gem when it is released.
23
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
- end
26
+ spec.files = Dir.chdir(File.expand_path(__dir__)) {
27
+ `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
28
+ }
27
29
  spec.bindir = "exe"
28
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
29
31
  spec.require_paths = ["lib"]
30
32
  spec.extensions = ["ext/d_heap/extconf.rb"]
33
+
34
+ spec.add_development_dependency "benchmark_driver"
35
+ spec.add_development_dependency "ruby-prof"
31
36
  end
@@ -0,0 +1,52 @@
1
+ Benchmarking run at 2021-01-11 23:29:03 -0500
2
+ ruby v2.7.2, DHeap v0.4.0
3
+
4
+ Warming up --------------------------------------
5
+ push + pop (findmin) 12.852k i/s - 13.364k times in 1.039832s (77.81μs/i)
6
+ push + pop (bsearch) 1.531M i/s - 1.603M times in 1.047477s (653.25ns/i)
7
+ push + pop (rb_heap) 485.963k i/s - 500.745k times in 1.030417s (2.06μs/i)
8
+ push + pop (c_dheap) 3.070M i/s - 3.147M times in 1.025047s (325.74ns/i, 687clocks/i)
9
+ Calculating -------------------------------------
10
+ bin/bench_n 20000 bin/bench_n 40000 bin/bench_n 60000 bin/bench_n 80000 bin/bench_n 100000 bin/bench_n 120000 bin/bench_n 140000
11
+ push + pop (findmin) 14.131k 6.039k 3.760k 2.727k 2.136k 1.736k 1.477k i/s - 38.556k times in 2.728481s 6.384254s 10.254074s 14.136144s 18.049587s 22.204711s 26.106433s
12
+ push + pop (bsearch) 1.544M 1.312M 1.118M 877.817k 697.832k 570.122k 459.166k i/s - 4.592M times in 2.975164s 3.500284s 4.107319s 5.231671s 6.581027s 8.055201s 10.001713s
13
+ push + pop (rb_heap) 539.712k 512.212k 499.451k 484.457k 452.217k 497.861k 412.057k i/s - 1.458M times in 2.701239s 2.846265s 2.918984s 3.009325s 3.223875s 2.928307s 3.538075s
14
+ push + pop (c_dheap) 3.153M 2.756M 2.831M 2.912M 2.539M 2.552M 2.587M i/s - 9.210M times in 2.921285s 3.341750s 3.252966s 3.162880s 3.627868s 3.608295s 3.560563s
15
+
16
+ Comparison:
17
+ push + pop (findmin)
18
+ bin/bench_n 20000: 14130.9 i/s
19
+ bin/bench_n 40000: 6039.2 i/s - 2.34x slower
20
+ bin/bench_n 60000: 3760.1 i/s - 3.76x slower
21
+ bin/bench_n 80000: 2727.5 i/s - 5.18x slower
22
+ bin/bench_n 100000: 2136.1 i/s - 6.62x slower
23
+ bin/bench_n 120000: 1736.4 i/s - 8.14x slower
24
+ bin/bench_n 140000: 1476.9 i/s - 9.57x slower
25
+
26
+ push + pop (bsearch)
27
+ bin/bench_n 20000: 1543594.7 i/s
28
+ bin/bench_n 40000: 1312021.6 i/s - 1.18x slower
29
+ bin/bench_n 60000: 1118113.4 i/s - 1.38x slower
30
+ bin/bench_n 80000: 877816.6 i/s - 1.76x slower
31
+ bin/bench_n 100000: 697831.5 i/s - 2.21x slower
32
+ bin/bench_n 120000: 570122.1 i/s - 2.71x slower
33
+ bin/bench_n 140000: 459166.2 i/s - 3.36x slower
34
+
35
+ push + pop (rb_heap)
36
+ bin/bench_n 20000: 539711.6 i/s
37
+ bin/bench_n 40000: 512211.7 i/s - 1.05x slower
38
+ bin/bench_n 60000: 499451.1 i/s - 1.08x slower
39
+ bin/bench_n 120000: 497861.1 i/s - 1.08x slower
40
+ bin/bench_n 80000: 484457.5 i/s - 1.11x slower
41
+ bin/bench_n 100000: 452216.7 i/s - 1.19x slower
42
+ bin/bench_n 140000: 412057.4 i/s - 1.31x slower
43
+
44
+ push + pop (c_dheap)
45
+ bin/bench_n 20000: 3152657.6 i/s
46
+ bin/bench_n 80000: 2911843.5 i/s - 1.08x slower
47
+ bin/bench_n 60000: 2831204.1 i/s - 1.11x slower
48
+ bin/bench_n 40000: 2755984.2 i/s - 1.14x slower
49
+ bin/bench_n 140000: 2586616.8 i/s - 1.22x slower
50
+ bin/bench_n 120000: 2552399.7 i/s - 1.24x slower
51
+ bin/bench_n 100000: 2538628.9 i/s - 1.24x slower
52
+
@@ -0,0 +1,443 @@
1
+ Benchmarking run at 2021-01-11 23:29:03 -0500
2
+ ruby v2.7.2, DHeap v0.4.0
3
+
4
+ ################################################################################
5
+ # Benchmarks with N=5 (t=10sec/benchmark)
6
+ ################################################################################
7
+
8
+ == push N (N=5) ================================================================
9
+ Warming up --------------------------------------
10
+ push N (bsearch) 931.441k i/s - 1.879M times in 2.017047s (1.07μs/i)
11
+ push N (rb_heap) 1.012M i/s - 2.029M times in 2.005686s (988.29ns/i)
12
+ push N (c_dheap) 1.665M i/s - 3.351M times in 2.012998s (600.72ns/i)
13
+ Calculating -------------------------------------
14
+ push N (bsearch) 946.364k i/s - 5.589M times in 5.905389s (1.06μs/i)
15
+ push N (rb_heap) 971.614k i/s - 6.071M times in 6.248476s (1.03μs/i)
16
+ push N (c_dheap) 1.701M i/s - 9.988M times in 5.870725s (587.77ns/i)
17
+
18
+ Comparison:
19
+ push N (c_dheap): 1701338.1 i/s
20
+ push N (rb_heap): 971614.1 i/s - 1.75x slower
21
+ push N (bsearch): 946363.7 i/s - 1.80x slower
22
+
23
+ == push N then pop N (N=5) ====================================================
24
+ Warming up --------------------------------------
25
+ push N + pop N (findmin) 816.694k i/s - 1.656M times in 2.028176s (1.22μs/i)
26
+ push N + pop N (bsearch) 770.442k i/s - 1.566M times in 2.032470s (1.30μs/i)
27
+ push N + pop N (rb_heap) 467.156k i/s - 971.112k times in 2.078774s (2.14μs/i)
28
+ push N + pop N (c_dheap) 1.072M i/s - 2.164M times in 2.018623s (933.02ns/i)
29
+ Calculating -------------------------------------
30
+ push N + pop N (findmin) 841.708k i/s - 4.900M times in 5.821693s (1.19μs/i)
31
+ push N + pop N (bsearch) 773.253k i/s - 4.623M times in 5.978188s (1.29μs/i)
32
+ push N + pop N (rb_heap) 471.853k i/s - 2.803M times in 5.940275s (2.12μs/i)
33
+ push N + pop N (c_dheap) 1.088M i/s - 6.431M times in 5.910898s (919.16ns/i)
34
+
35
+ Comparison:
36
+ push N + pop N (c_dheap): 1087944.8 i/s
37
+ push N + pop N (findmin): 841708.1 i/s - 1.29x slower
38
+ push N + pop N (bsearch): 773252.7 i/s - 1.41x slower
39
+ push N + pop N (rb_heap): 471852.9 i/s - 2.31x slower
40
+
41
+ == Push/pop with pre-filled queue (size=N) (N=5) ==============================
42
+ Warming up --------------------------------------
43
+ push + pop (findmin) 5.151M i/s - 10.467M times in 2.032075s (194.13ns/i, 464clocks/i)
44
+ push + pop (bsearch) 4.021M i/s - 8.148M times in 2.026548s (248.72ns/i, 664clocks/i)
45
+ push + pop (rb_heap) 2.158M i/s - 4.445M times in 2.059708s (463.35ns/i)
46
+ push + pop (c_dheap) 5.185M i/s - 10.373M times in 2.000519s (192.86ns/i, 483clocks/i)
47
+ Calculating -------------------------------------
48
+ push + pop (findmin) 5.004M i/s - 30.906M times in 6.176454s (199.84ns/i, 413clocks/i)
49
+ push + pop (bsearch) 4.321M i/s - 24.124M times in 5.583405s (231.45ns/i, 647clocks/i)
50
+ push + pop (rb_heap) 2.207M i/s - 12.949M times in 5.867179s (453.10ns/i)
51
+ push + pop (c_dheap) 5.525M i/s - 31.111M times in 5.630456s (180.98ns/i, 458clocks/i)
52
+
53
+ Comparison:
54
+ push + pop (c_dheap): 5525418.8 i/s
55
+ push + pop (findmin): 5003904.8 i/s - 1.10x slower
56
+ push + pop (bsearch): 4320581.8 i/s - 1.28x slower
57
+ push + pop (rb_heap): 2207042.0 i/s - 2.50x slower
58
+
59
+ ################################################################################
60
+ # Benchmarks with N=21 (t=10sec/benchmark)
61
+ ################################################################################
62
+
63
+ == push N (N=21) ==============================================================
64
+ Warming up --------------------------------------
65
+ push N (bsearch) 170.251k i/s - 355.419k times in 2.087615s (5.87μs/i)
66
+ push N (rb_heap) 212.048k i/s - 442.865k times in 2.088508s (4.72μs/i)
67
+ push N (c_dheap) 391.469k i/s - 801.504k times in 2.047426s (2.55μs/i)
68
+ Calculating -------------------------------------
69
+ push N (bsearch) 169.583k i/s - 1.022M times in 6.023633s (5.90μs/i)
70
+ push N (rb_heap) 212.275k i/s - 1.272M times in 5.993587s (4.71μs/i)
71
+ push N (c_dheap) 408.307k i/s - 2.349M times in 5.752569s (2.45μs/i)
72
+
73
+ Comparison:
74
+ push N (c_dheap): 408307.0 i/s
75
+ push N (rb_heap): 212275.2 i/s - 1.92x slower
76
+ push N (bsearch): 169583.2 i/s - 2.41x slower
77
+
78
+ == push N then pop N (N=21) ====================================================
79
+ Warming up --------------------------------------
80
+ push N + pop N (findmin) 166.784k i/s - 344.938k times in 2.068173s (6.00μs/i)
81
+ push N + pop N (bsearch) 145.768k i/s - 304.502k times in 2.088957s (6.86μs/i)
82
+ push N + pop N (rb_heap) 69.234k i/s - 143.020k times in 2.065750s (14.44μs/i)
83
+ push N + pop N (c_dheap) 198.924k i/s - 414.304k times in 2.082722s (5.03μs/i)
84
+ Calculating -------------------------------------
85
+ push N + pop N (findmin) 162.025k i/s - 1.001M times in 6.176244s (6.17μs/i)
86
+ push N + pop N (bsearch) 146.284k i/s - 874.605k times in 5.978803s (6.84μs/i)
87
+ push N + pop N (rb_heap) 72.289k i/s - 415.403k times in 5.746419s (13.83μs/i)
88
+ push N + pop N (c_dheap) 199.435k i/s - 1.194M times in 5.984617s (5.01μs/i)
89
+
90
+ Comparison:
91
+ push N + pop N (c_dheap): 199435.5 i/s
92
+ push N + pop N (findmin): 162024.5 i/s - 1.23x slower
93
+ push N + pop N (bsearch): 146284.3 i/s - 1.36x slower
94
+ push N + pop N (rb_heap): 72289.0 i/s - 2.76x slower
95
+
96
+ == Push/pop with pre-filled queue (size=N) (N=21) ==============================
97
+ Warming up --------------------------------------
98
+ push + pop (findmin) 4.230M i/s - 8.548M times in 2.020984s (236.43ns/i, 633clocks/i)
99
+ push + pop (bsearch) 3.257M i/s - 6.630M times in 2.035714s (307.06ns/i, 669clocks/i)
100
+ push + pop (rb_heap) 1.544M i/s - 3.159M times in 2.045247s (647.47ns/i)
101
+ push + pop (c_dheap) 4.705M i/s - 9.501M times in 2.019236s (212.53ns/i, 533clocks/i)
102
+ Calculating -------------------------------------
103
+ push + pop (findmin) 4.467M i/s - 25.378M times in 5.680532s (223.84ns/i, 551clocks/i)
104
+ push + pop (bsearch) 3.345M i/s - 19.540M times in 5.840823s (298.91ns/i, 831clocks/i)
105
+ push + pop (rb_heap) 1.560M i/s - 9.267M times in 5.938451s (640.83ns/i)
106
+ push + pop (c_dheap) 4.837M i/s - 28.231M times in 5.836574s (206.75ns/i, 591clocks/i)
107
+
108
+ Comparison:
109
+ push + pop (c_dheap): 4836860.0 i/s
110
+ push + pop (findmin): 4467453.9 i/s - 1.08x slower
111
+ push + pop (bsearch): 3345458.4 i/s - 1.45x slower
112
+ push + pop (rb_heap): 1560476.3 i/s - 3.10x slower
113
+
114
+ ################################################################################
115
+ # Benchmarks with N=85 (t=10sec/benchmark)
116
+ ################################################################################
117
+
118
+ == push N (N=85) ==============================================================
119
+ Warming up --------------------------------------
120
+ push N (bsearch) 33.491k i/s - 69.846k times in 2.085516s (29.86μs/i)
121
+ push N (rb_heap) 43.880k i/s - 91.665k times in 2.089004s (22.79μs/i)
122
+ push N (c_dheap) 93.190k i/s - 193.557k times in 2.077020s (10.73μs/i)
123
+ Calculating -------------------------------------
124
+ push N (bsearch) 33.118k i/s - 200.945k times in 6.067575s (30.20μs/i)
125
+ push N (rb_heap) 47.069k i/s - 263.278k times in 5.593458s (21.25μs/i)
126
+ push N (c_dheap) 96.077k i/s - 559.138k times in 5.819670s (10.41μs/i)
127
+
128
+ Comparison:
129
+ push N (c_dheap): 96077.3 i/s
130
+ push N (rb_heap): 47068.9 i/s - 2.04x slower
131
+ push N (bsearch): 33117.8 i/s - 2.90x slower
132
+
133
+ == push N then pop N (N=85) ====================================================
134
+ Warming up --------------------------------------
135
+ push N + pop N (findmin) 27.530k i/s - 57.351k times in 2.083246s (36.32μs/i)
136
+ push N + pop N (bsearch) 29.264k i/s - 59.283k times in 2.025786s (34.17μs/i)
137
+ push N + pop N (rb_heap) 13.281k i/s - 27.783k times in 2.091902s (75.29μs/i)
138
+ push N + pop N (c_dheap) 42.532k i/s - 87.318k times in 2.052993s (23.51μs/i)
139
+ Calculating -------------------------------------
140
+ push N + pop N (findmin) 27.615k i/s - 165.177k times in 5.981465s (36.21μs/i)
141
+ push N + pop N (bsearch) 29.643k i/s - 175.585k times in 5.923305s (33.73μs/i)
142
+ push N + pop N (rb_heap) 13.267k i/s - 79.687k times in 6.006463s (75.38μs/i)
143
+ push N + pop N (c_dheap) 41.943k i/s - 255.192k times in 6.084224s (23.84μs/i)
144
+
145
+ Comparison:
146
+ push N + pop N (c_dheap): 41943.2 i/s
147
+ push N + pop N (bsearch): 29643.1 i/s - 1.41x slower
148
+ push N + pop N (findmin): 27614.8 i/s - 1.52x slower
149
+ push N + pop N (rb_heap): 13266.9 i/s - 3.16x slower
150
+
151
+ == Push/pop with pre-filled queue (size=N) (N=85) ==============================
152
+ Warming up --------------------------------------
153
+ push + pop (findmin) 3.070M i/s - 6.171M times in 2.009864s (325.70ns/i, 854clocks/i)
154
+ push + pop (bsearch) 2.693M i/s - 5.458M times in 2.026866s (371.36ns/i)
155
+ push + pop (rb_heap) 1.285M i/s - 2.598M times in 2.021618s (778.13ns/i)
156
+ push + pop (c_dheap) 4.250M i/s - 8.596M times in 2.022749s (235.30ns/i, 676clocks/i)
157
+ Calculating -------------------------------------
158
+ push + pop (findmin) 3.221M i/s - 18.422M times in 5.719316s (310.46ns/i, 843clocks/i)
159
+ push + pop (bsearch) 2.721M i/s - 16.157M times in 5.937334s (367.48ns/i, 815clocks/i)
160
+ push + pop (rb_heap) 1.219M i/s - 7.711M times in 6.326403s (820.46ns/i)
161
+ push + pop (c_dheap) 4.309M i/s - 25.499M times in 5.917551s (232.07ns/i, 615clocks/i)
162
+
163
+ Comparison:
164
+ push + pop (c_dheap): 4309094.2 i/s
165
+ push + pop (findmin): 3221024.5 i/s - 1.34x slower
166
+ push + pop (bsearch): 2721221.4 i/s - 1.58x slower
167
+ push + pop (rb_heap): 1218828.1 i/s - 3.54x slower
168
+
169
+ ################################################################################
170
+ # Benchmarks with N=341 (t=10sec/benchmark)
171
+ ################################################################################
172
+
173
+ == push N (N=341) ==============================================================
174
+ Warming up --------------------------------------
175
+ push N (bsearch) 6.749k i/s - 13.500k times in 2.000413s (148.18μs/i)
176
+ push N (rb_heap) 11.089k i/s - 23.142k times in 2.086845s (90.18μs/i)
177
+ push N (c_dheap) 24.122k i/s - 50.652k times in 2.099804s (41.46μs/i)
178
+ Calculating -------------------------------------
179
+ push N (bsearch) 6.480k i/s - 40.491k times in 6.248994s (154.33μs/i)
180
+ push N (rb_heap) 11.533k i/s - 66.536k times in 5.769108s (86.71μs/i)
181
+ push N (c_dheap) 24.443k i/s - 144.733k times in 5.921130s (40.91μs/i)
182
+
183
+ Comparison:
184
+ push N (c_dheap): 24443.5 i/s
185
+ push N (rb_heap): 11533.2 i/s - 2.12x slower
186
+ push N (bsearch): 6479.6 i/s - 3.77x slower
187
+
188
+ == push N then pop N (N=341) ==================================================
189
+ Warming up --------------------------------------
190
+ push N + pop N (findmin) 3.022k i/s - 6.100k times in 2.018293s (330.87μs/i)
191
+ push N + pop N (bsearch) 5.731k i/s - 11.660k times in 2.034429s (174.48μs/i)
192
+ push N + pop N (rb_heap) 2.587k i/s - 5.200k times in 2.009894s (386.52μs/i)
193
+ push N + pop N (c_dheap) 9.199k i/s - 19.341k times in 2.102558s (108.71μs/i)
194
+ Calculating -------------------------------------
195
+ push N + pop N (findmin) 2.987k i/s - 18.134k times in 6.070835s (334.78μs/i)
196
+ push N + pop N (bsearch) 6.084k i/s - 34.388k times in 5.651801s (164.35μs/i)
197
+ push N + pop N (rb_heap) 2.485k i/s - 15.523k times in 6.246007s (402.37μs/i)
198
+ push N + pop N (c_dheap) 9.378k i/s - 55.192k times in 5.885032s (106.63μs/i)
199
+
200
+ Comparison:
201
+ push N + pop N (c_dheap): 9378.4 i/s
202
+ push N + pop N (bsearch): 6084.4 i/s - 1.54x slower
203
+ push N + pop N (findmin): 2987.1 i/s - 3.14x slower
204
+ push N + pop N (rb_heap): 2485.3 i/s - 3.77x slower
205
+
206
+ == Push/pop with pre-filled queue (size=N) (N=341) ============================
207
+ Warming up --------------------------------------
208
+ push + pop (findmin) 1.521M i/s - 3.136M times in 2.061814s (657.42ns/i)
209
+ push + pop (bsearch) 2.204M i/s - 4.426M times in 2.007702s (453.65ns/i)
210
+ push + pop (rb_heap) 979.272k i/s - 2.030M times in 2.073290s (1.02μs/i)
211
+ push + pop (c_dheap) 3.709M i/s - 7.536M times in 2.031644s (269.60ns/i, 700clocks/i)
212
+ Calculating -------------------------------------
213
+ push + pop (findmin) 1.546M i/s - 9.127M times in 5.904088s (646.91ns/i)
214
+ push + pop (bsearch) 2.183M i/s - 13.226M times in 6.058119s (458.04ns/i)
215
+ push + pop (rb_heap) 973.052k i/s - 5.876M times in 6.038353s (1.03μs/i)
216
+ push + pop (c_dheap) 3.896M i/s - 22.255M times in 5.712835s (256.69ns/i, 748clocks/i)
217
+
218
+ Comparison:
219
+ push + pop (c_dheap): 3895683.1 i/s
220
+ push + pop (bsearch): 2183202.6 i/s - 1.78x slower
221
+ push + pop (findmin): 1545816.8 i/s - 2.52x slower
222
+ push + pop (rb_heap): 973051.6 i/s - 4.00x slower
223
+
224
+ ################################################################################
225
+ # Benchmarks with N=1365 (t=10sec/benchmark)
226
+ ################################################################################
227
+
228
+ == push N (N=1365) ============================================================
229
+ Warming up --------------------------------------
230
+ push N (bsearch) 1.371k i/s - 2.800k times in 2.041823s (729.22μs/i)
231
+ push N (rb_heap) 2.863k i/s - 6.006k times in 2.097685s (349.26μs/i)
232
+ push N (c_dheap) 5.730k i/s - 11.840k times in 2.066292s (174.52μs/i)
233
+ Calculating -------------------------------------
234
+ push N (bsearch) 1.362k i/s - 8.227k times in 6.041325s (734.33μs/i)
235
+ push N (rb_heap) 2.615k i/s - 17.178k times in 6.568916s (382.40μs/i)
236
+ push N (c_dheap) 5.775k i/s - 34.380k times in 5.953356s (173.16μs/i)
237
+
238
+ Comparison:
239
+ push N (c_dheap): 5774.9 i/s
240
+ push N (rb_heap): 2615.0 i/s - 2.21x slower
241
+ push N (bsearch): 1361.8 i/s - 4.24x slower
242
+
243
+ == push N then pop N (N=1365) ==================================================
244
+ Warming up --------------------------------------
245
+ push N + pop N (findmin) 196.660 i/s - 400.000 times in 2.033965s (5.08ms/i)
246
+ push N + pop N (bsearch) 1.197k i/s - 2.457k times in 2.052435s (835.34μs/i)
247
+ push N + pop N (rb_heap) 539.093 i/s - 1.080k times in 2.003367s (1.85ms/i)
248
+ push N + pop N (c_dheap) 2.012k i/s - 4.158k times in 2.066145s (496.91μs/i)
249
+ Calculating -------------------------------------
250
+ push N + pop N (findmin) 193.288 i/s - 1.179k times in 6.099704s (5.17ms/i)
251
+ push N + pop N (bsearch) 1.282k i/s - 7.182k times in 5.602801s (780.12μs/i)
252
+ push N + pop N (rb_heap) 528.397 i/s - 3.234k times in 6.120397s (1.89ms/i)
253
+ push N + pop N (c_dheap) 2.073k i/s - 12.074k times in 5.824461s (482.40μs/i)
254
+
255
+ Comparison:
256
+ push N + pop N (c_dheap): 2073.0 i/s
257
+ push N + pop N (bsearch): 1281.9 i/s - 1.62x slower
258
+ push N + pop N (rb_heap): 528.4 i/s - 3.92x slower
259
+ push N + pop N (findmin): 193.3 i/s - 10.72x slower
260
+
261
+ == Push/pop with pre-filled queue (size=N) (N=1365) ============================
262
+ Warming up --------------------------------------
263
+ push + pop (findmin) 493.933k i/s - 1.023M times in 2.071688s (2.02μs/i)
264
+ push + pop (bsearch) 1.972M i/s - 3.978M times in 2.017663s (507.20ns/i)
265
+ push + pop (rb_heap) 813.919k i/s - 1.646M times in 2.021751s (1.23μs/i)
266
+ push + pop (c_dheap) 2.969M i/s - 6.033M times in 2.032182s (336.83ns/i, 846clocks/i)
267
+ Calculating -------------------------------------
268
+ push + pop (findmin) 493.104k i/s - 2.964M times in 6.010080s (2.03μs/i)
269
+ push + pop (bsearch) 2.002M i/s - 11.830M times in 5.908100s (499.43ns/i)
270
+ push + pop (rb_heap) 831.926k i/s - 4.884M times in 5.870129s (1.20μs/i)
271
+ push + pop (c_dheap) 3.117M i/s - 17.813M times in 5.714019s (320.77ns/i, 787clocks/i)
272
+
273
+ Comparison:
274
+ push + pop (c_dheap): 3117453.6 i/s
275
+ push + pop (bsearch): 2002296.0 i/s - 1.56x slower
276
+ push + pop (rb_heap): 831926.4 i/s - 3.75x slower
277
+ push + pop (findmin): 493104.4 i/s - 6.32x slower
278
+
279
+ ################################################################################
280
+ # Benchmarks with N=5461 (t=10sec/benchmark)
281
+ ################################################################################
282
+
283
+ == push N (N=5461) ============================================================
284
+ Warming up --------------------------------------
285
+ push N (bsearch) 271.804 i/s - 567.000 times in 2.086065s (3.68ms/i)
286
+ push N (rb_heap) 708.260 i/s - 1.440k times in 2.033152s (1.41ms/i)
287
+ push N (c_dheap) 1.523k i/s - 3.171k times in 2.082653s (656.78μs/i)
288
+ Calculating -------------------------------------
289
+ push N (bsearch) 268.014 i/s - 1.630k times in 6.081766s (3.73ms/i)
290
+ push N (rb_heap) 682.522 i/s - 4.249k times in 6.225438s (1.47ms/i)
291
+ push N (c_dheap) 1.494k i/s - 9.135k times in 6.113865s (669.28μs/i)
292
+
293
+ Comparison:
294
+ push N (c_dheap): 1494.1 i/s
295
+ push N (rb_heap): 682.5 i/s - 2.19x slower
296
+ push N (bsearch): 268.0 i/s - 5.57x slower
297
+
298
+ == push N then pop N (N=5461) ==================================================
299
+ Warming up --------------------------------------
300
+ push N + pop N (findmin) 12.484 i/s - 26.000 times in 2.082741s (80.11ms/i)
301
+ push N + pop N (bsearch) 250.220 i/s - 520.000 times in 2.078172s (4.00ms/i)
302
+ push N + pop N (rb_heap) 115.535 i/s - 240.000 times in 2.077301s (8.66ms/i)
303
+ push N + pop N (c_dheap) 454.895 i/s - 920.000 times in 2.022444s (2.20ms/i)
304
+ Calculating -------------------------------------
305
+ push N + pop N (findmin) 12.423 i/s - 74.000 times in 5.956886s (80.50ms/i)
306
+ push N + pop N (bsearch) 247.409 i/s - 1.501k times in 6.066870s (4.04ms/i)
307
+ push N + pop N (rb_heap) 112.159 i/s - 693.000 times in 6.178754s (8.92ms/i)
308
+ push N + pop N (c_dheap) 452.913 i/s - 2.729k times in 6.025436s (2.21ms/i)
309
+
310
+ Comparison:
311
+ push N + pop N (c_dheap): 452.9 i/s
312
+ push N + pop N (bsearch): 247.4 i/s - 1.83x slower
313
+ push N + pop N (rb_heap): 112.2 i/s - 4.04x slower
314
+ push N + pop N (findmin): 12.4 i/s - 36.46x slower
315
+
316
+ == Push/pop with pre-filled queue (size=N) (N=5461) ============================
317
+ Warming up --------------------------------------
318
+ push + pop (findmin) 124.542k i/s - 250.908k times in 2.014649s (8.03μs/i)
319
+ push + pop (bsearch) 1.610M i/s - 3.242M times in 2.013150s (620.93ns/i)
320
+ push + pop (rb_heap) 704.201k i/s - 1.416M times in 2.010517s (1.42μs/i)
321
+ push + pop (c_dheap) 2.563M i/s - 5.170M times in 2.017119s (390.19ns/i)
322
+ Calculating -------------------------------------
323
+ push + pop (findmin) 122.316k i/s - 747.250k times in 6.109176s (8.18μs/i)
324
+ push + pop (bsearch) 1.794M i/s - 9.663M times in 5.387620s (557.55ns/i)
325
+ push + pop (rb_heap) 707.140k i/s - 4.225M times in 5.975062s (1.41μs/i)
326
+ push + pop (c_dheap) 2.718M i/s - 15.377M times in 5.656979s (367.89ns/i)
327
+
328
+ Comparison:
329
+ push + pop (c_dheap): 2718225.1 i/s
330
+ push + pop (bsearch): 1793546.4 i/s - 1.52x slower
331
+ push + pop (rb_heap): 707139.9 i/s - 3.84x slower
332
+ push + pop (findmin): 122316.0 i/s - 22.22x slower
333
+
334
+ ################################################################################
335
+ # Benchmarks with N=21845 (t=10sec/benchmark)
336
+ ################################################################################
337
+
338
+ == push N (N=21845) ============================================================
339
+ Warming up --------------------------------------
340
+ push N (bsearch) 35.384 i/s - 72.000 times in 2.034790s (28.26ms/i)
341
+ push N (rb_heap) 172.946 i/s - 360.000 times in 2.081571s (5.78ms/i)
342
+ push N (c_dheap) 364.900 i/s - 740.000 times in 2.027956s (2.74ms/i)
343
+ Calculating -------------------------------------
344
+ push N (bsearch) 34.023 i/s - 212.000 times in 6.231133s (29.39ms/i)
345
+ push N (rb_heap) 174.336 i/s - 1.037k times in 5.948268s (5.74ms/i)
346
+ push N (c_dheap) 368.253 i/s - 2.189k times in 5.944276s (2.72ms/i)
347
+
348
+ Comparison:
349
+ push N (c_dheap): 368.3 i/s
350
+ push N (rb_heap): 174.3 i/s - 2.11x slower
351
+ push N (bsearch): 34.0 i/s - 10.82x slower
352
+
353
+ == push N then pop N (N=21845) ================================================
354
+ Warming up --------------------------------------
355
+ push N + pop N (findmin) 0.779 i/s - 2.000 times in 2.566006s (1.28s/i)
356
+ push N + pop N (bsearch) 34.145 i/s - 72.000 times in 2.108676s (29.29ms/i)
357
+ push N + pop N (rb_heap) 24.870 i/s - 51.000 times in 2.050656s (40.21ms/i)
358
+ push N + pop N (c_dheap) 102.725 i/s - 209.000 times in 2.034560s (9.73ms/i)
359
+ Calculating -------------------------------------
360
+ push N + pop N (findmin) 0.777 i/s - 4.000 times in 5.148214s (1.29s/i)
361
+ push N + pop N (bsearch) 33.931 i/s - 204.000 times in 6.012272s (29.47ms/i)
362
+ push N + pop N (rb_heap) 25.005 i/s - 149.000 times in 5.958910s (39.99ms/i)
363
+ push N + pop N (c_dheap) 101.482 i/s - 616.000 times in 6.070050s (9.85ms/i)
364
+
365
+ Comparison:
366
+ push N + pop N (c_dheap): 101.5 i/s
367
+ push N + pop N (bsearch): 33.9 i/s - 2.99x slower
368
+ push N + pop N (rb_heap): 25.0 i/s - 4.06x slower
369
+ push N + pop N (findmin): 0.8 i/s - 130.61x slower
370
+
371
+ == Push/pop with pre-filled queue (size=N) (N=21845) ==========================
372
+ Warming up --------------------------------------
373
+ push + pop (findmin) 13.737k i/s - 27.540k times in 2.004757s (72.79μs/i)
374
+ push + pop (bsearch) 1.512M i/s - 3.037M times in 2.008949s (661.44ns/i)
375
+ push + pop (rb_heap) 606.616k i/s - 1.239M times in 2.042544s (1.65μs/i)
376
+ push + pop (c_dheap) 2.034M i/s - 4.134M times in 2.032566s (491.70ns/i)
377
+ Calculating -------------------------------------
378
+ push + pop (findmin) 15.583k i/s - 82.423k times in 5.289229s (64.17μs/i)
379
+ push + pop (bsearch) 1.575M i/s - 9.071M times in 5.760389s (635.03ns/i)
380
+ push + pop (rb_heap) 611.005k i/s - 3.640M times in 5.956897s (1.64μs/i)
381
+ push + pop (c_dheap) 2.264M i/s - 12.203M times in 5.389179s (441.64ns/i)
382
+
383
+ Comparison:
384
+ push + pop (c_dheap): 2264291.2 i/s
385
+ push + pop (bsearch): 1574732.8 i/s - 1.44x slower
386
+ push + pop (rb_heap): 611005.2 i/s - 3.71x slower
387
+ push + pop (findmin): 15583.2 i/s - 145.30x slower
388
+
389
+ ################################################################################
390
+ # Benchmarks with N=87381 (t=10sec/benchmark)
391
+ ################################################################################
392
+
393
+ == push N (N=87381) ============================================================
394
+ Warming up --------------------------------------
395
+ push N (bsearch) 2.973 i/s - 6.000 times in 2.017930s (336.32ms/i)
396
+ push N (rb_heap) 43.444 i/s - 90.000 times in 2.071609s (23.02ms/i)
397
+ push N (c_dheap) 93.043 i/s - 190.000 times in 2.042069s (10.75ms/i)
398
+ Calculating -------------------------------------
399
+ push N (bsearch) 2.929 i/s - 17.000 times in 5.805017s (341.47ms/i)
400
+ push N (rb_heap) 43.528 i/s - 260.000 times in 5.973114s (22.97ms/i)
401
+ push N (c_dheap) 92.841 i/s - 558.000 times in 6.010303s (10.77ms/i)
402
+
403
+ Comparison:
404
+ push N (c_dheap): 92.8 i/s
405
+ push N (rb_heap): 43.5 i/s - 2.13x slower
406
+ push N (bsearch): 2.9 i/s - 31.70x slower
407
+
408
+ == push N then pop N (N=87381) ================================================
409
+ Warming up --------------------------------------
410
+ push N + pop N (findmin)0.0 i/s - 0.0 times in 15.004208s (Infs/i)
411
+ push N + pop N (bsearch) 2.904 i/s - 6.000 times in 2.066042s (344.34ms/i)
412
+ push N + pop N (rb_heap) 5.506 i/s - 12.000 times in 2.179391s (181.62ms/i)
413
+ push N + pop N (c_dheap) 22.529 i/s - 48.000 times in 2.130599s (44.39ms/i)
414
+ Calculating -------------------------------------
415
+ push N + pop N (findmin)0.0 i/s - 0.0 times in 15.004208s (Infs/i)
416
+ push N + pop N (bsearch) 2.861 i/s - 17.000 times in 5.942237s (349.54ms/i)
417
+ push N + pop N (rb_heap) 5.540 i/s - 33.000 times in 5.956511s (180.50ms/i)
418
+ push N + pop N (c_dheap) 22.614 i/s - 135.000 times in 5.969706s (44.22ms/i)
419
+
420
+ Comparison:
421
+ push N + pop N (c_dheap): 22.6 i/s
422
+ push N + pop N (rb_heap): 5.5 i/s - 4.08x slower
423
+ push N + pop N (bsearch): 2.9 i/s - 7.90x slower
424
+ push N + pop N (findmin): 0.0 i/s - Infx slower
425
+
426
+ == Push/pop with pre-filled queue (size=N) (N=87381) ==========================
427
+ Warming up --------------------------------------
428
+ push + pop (findmin) 2.275k i/s - 4.683k times in 2.058769s (439.63μs/i)
429
+ push + pop (bsearch) 682.628k i/s - 1.372M times in 2.010489s (1.46μs/i)
430
+ push + pop (rb_heap) 519.439k i/s - 1.058M times in 2.037582s (1.93μs/i)
431
+ push + pop (c_dheap) 1.713M i/s - 3.455M times in 2.016970s (583.83ns/i)
432
+ Calculating -------------------------------------
433
+ push + pop (findmin) 2.263k i/s - 13.647k times in 6.031111s (441.94μs/i)
434
+ push + pop (bsearch) 762.343k i/s - 4.096M times in 5.372602s (1.31μs/i)
435
+ push + pop (rb_heap) 535.914k i/s - 3.117M times in 5.815555s (1.87μs/i)
436
+ push + pop (c_dheap) 1.815M i/s - 10.277M times in 5.661404s (550.88ns/i)
437
+
438
+ Comparison:
439
+ push + pop (c_dheap): 1815277.3 i/s
440
+ push + pop (bsearch): 762343.2 i/s - 2.38x slower
441
+ push + pop (rb_heap): 535913.6 i/s - 3.39x slower
442
+ push + pop (findmin): 2262.8 i/s - 802.24x slower
443
+