d_heap 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +2 -2
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/.yardopts +10 -0
- data/CHANGELOG.md +19 -6
- data/Gemfile +4 -0
- data/Gemfile.lock +10 -1
- data/N +7 -0
- data/README.md +185 -231
- data/benchmarks/push_n.yml +10 -6
- data/benchmarks/push_n_pop_n.yml +27 -10
- data/benchmarks/push_pop.yml +5 -0
- data/bin/bench_charts +13 -0
- data/d_heap.gemspec +1 -1
- data/ext/d_heap/d_heap.c +435 -140
- data/ext/d_heap/extconf.rb +3 -4
- data/images/push_n.png +0 -0
- data/images/push_n_pop_n.png +0 -0
- data/images/push_pop.png +0 -0
- data/images/wikipedia-min-heap.png +0 -0
- data/lib/benchmark_driver/runner/ips_zero_fail.rb +89 -51
- data/lib/d_heap.rb +81 -18
- data/lib/d_heap/benchmarks/implementations.rb +30 -28
- data/lib/d_heap/benchmarks/rspec_matchers.rb +29 -51
- data/lib/d_heap/version.rb +1 -1
- metadata +10 -4
- data/ext/d_heap/d_heap.h +0 -50
data/lib/d_heap/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: d_heap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nicholas a. evans
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark_driver
|
@@ -53,11 +53,13 @@ files:
|
|
53
53
|
- ".rspec"
|
54
54
|
- ".rubocop.yml"
|
55
55
|
- ".travis.yml"
|
56
|
+
- ".yardopts"
|
56
57
|
- CHANGELOG.md
|
57
58
|
- CODE_OF_CONDUCT.md
|
58
59
|
- Gemfile
|
59
60
|
- Gemfile.lock
|
60
61
|
- LICENSE.txt
|
62
|
+
- N
|
61
63
|
- README.md
|
62
64
|
- Rakefile
|
63
65
|
- benchmarks/perf.rb
|
@@ -65,6 +67,7 @@ files:
|
|
65
67
|
- benchmarks/push_n_pop_n.yml
|
66
68
|
- benchmarks/push_pop.yml
|
67
69
|
- benchmarks/stackprof.rb
|
70
|
+
- bin/bench_charts
|
68
71
|
- bin/bench_n
|
69
72
|
- bin/benchmark-driver
|
70
73
|
- bin/benchmarks
|
@@ -80,8 +83,11 @@ files:
|
|
80
83
|
- docs/benchmarks.txt
|
81
84
|
- docs/profile.txt
|
82
85
|
- ext/d_heap/d_heap.c
|
83
|
-
- ext/d_heap/d_heap.h
|
84
86
|
- ext/d_heap/extconf.rb
|
87
|
+
- images/push_n.png
|
88
|
+
- images/push_n_pop_n.png
|
89
|
+
- images/push_pop.png
|
90
|
+
- images/wikipedia-min-heap.png
|
85
91
|
- lib/benchmark_driver/runner/ips_zero_fail.rb
|
86
92
|
- lib/d_heap.rb
|
87
93
|
- lib/d_heap/benchmarks.rb
|
@@ -105,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
111
|
requirements:
|
106
112
|
- - ">="
|
107
113
|
- !ruby/object:Gem::Version
|
108
|
-
version: 2.
|
114
|
+
version: 2.4.0
|
109
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
116
|
requirements:
|
111
117
|
- - ">="
|
data/ext/d_heap/d_heap.h
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
#ifndef D_HEAP_H
|
2
|
-
#define D_HEAP_H 1
|
3
|
-
|
4
|
-
#include "ruby.h"
|
5
|
-
|
6
|
-
// d=4 uses the fewest comparisons for insert + delete-min (in the worst case).
|
7
|
-
#define DHEAP_DEFAULT_D 4
|
8
|
-
|
9
|
-
// This is a somewhat arbitary maximum. But benefits from more leaf nodes
|
10
|
-
// are very unlikely to outweigh the increasinly higher number of worst-case
|
11
|
-
// comparisons as d gets further from 4.
|
12
|
-
#define DHEAP_MAX_D 32
|
13
|
-
|
14
|
-
typedef long double SCORE;
|
15
|
-
|
16
|
-
typedef struct dheap_entry {
|
17
|
-
SCORE score;
|
18
|
-
VALUE value;
|
19
|
-
} ENTRY;
|
20
|
-
|
21
|
-
#define DHEAP_DEFAULT_SIZE 256
|
22
|
-
#define DHEAP_MAX_SIZE (LONG_MAX / (int)sizeof(ENTRY))
|
23
|
-
|
24
|
-
#define DHEAP_CAPA_INCR_MAX (10 * 1024 * 1024 / (int)sizeof(ENTRY))
|
25
|
-
|
26
|
-
VALUE rb_cDHeap;
|
27
|
-
|
28
|
-
// copied from pg gem
|
29
|
-
|
30
|
-
#define UNUSED(x) ((void)(x))
|
31
|
-
|
32
|
-
#ifdef HAVE_RB_GC_MARK_MOVABLE
|
33
|
-
#define dheap_compact_callback(x) ((void (*)(void*))(x))
|
34
|
-
#define dheap_gc_location(x) x = rb_gc_location(x)
|
35
|
-
#else
|
36
|
-
#define rb_gc_mark_movable(x) rb_gc_mark(x)
|
37
|
-
#define dheap_compact_callback(x) {(x)}
|
38
|
-
#define dheap_gc_location(x) UNUSED(x)
|
39
|
-
#endif
|
40
|
-
|
41
|
-
#ifdef __D_HEAP_DEBUG
|
42
|
-
#define debug(v) { \
|
43
|
-
ID sym_puts = rb_intern("puts"); \
|
44
|
-
rb_funcall(rb_mKernel, sym_puts, 1, v); \
|
45
|
-
}
|
46
|
-
#else
|
47
|
-
#define debug(v)
|
48
|
-
#endif
|
49
|
-
|
50
|
-
#endif /* D_HEAP_H */
|