@@ -15,53 +15,71 @@ BinarySearch is a Ruby gem that implements a self-balancing binary search tree u
15
15
16
16
## Benchmark results:
17
17
``` bash
18
+ ruby 3.3.3 (2024-06-12 revision f1c7b6f435) +YJIT [x86_64-linux]
18
19
Benchmarking with 10,000 elements:
19
- user system total real
20
- Array insert: 0.000455 0.000000 0.000455 ( 0.000453)
21
- BinarySearch insert: 0.010808 0.000735 0.011543 ( 0.011955)
22
- NArray insert: 0.000023 0.000007 0.000030 ( 0.000030)
23
- Array search: 0.149230 0.000000 0.149230 ( 0.149390)
24
- BinarySearch search: 0.001719 0.000000 0.001719 ( 0.001720)
25
- NArray search: 0.210021 0.000861 0.210882 ( 0.210903)
26
- Array delete: 0.466095 0.000000 0.466095 ( 0.466142)
27
- BinarySearch delete: 0.006978 0.000986 0.007964 ( 0.007965)
28
- NArray delete: 0.344920 0.045966 0.390886 ( 0.391025)
20
+ user system total real
21
+ Array#<< (append): 0.000318 0.000083 0.000401 ( 0.000398)
22
+ BinarySearch GEM#insert: 0.012594 0.000000 0.012594 ( 0.012609)
23
+ Numo::NArray.new + .seq: 0.000042 0.000000 0.000042 ( 0.000042)
24
+ SortedSet#add: 0.008358 0.001024 0.009382 ( 0.009516)
25
+ Array#include?: 0.150862 0.000000 0.150862 ( 0.150930)
26
+ BinarySearch GEM#include?: 0.001820 0.000000 0.001820 ( 0.001821)
27
+ Numo::NArray#eq + .any?: 0.215213 0.000000 0.215213 ( 0.215412)
28
+ Array#bsearch (std lib): 0.004166 0.000000 0.004166 ( 0.004166)
29
+ Array#delete: 0.471802 0.000000 0.471802 ( 0.471888)
30
+ BinarySearch GEM#delete: 0.007105 0.000991 0.008096 ( 0.008099)
31
+ Numo::NArray delete (mask): 0.363630 0.039971 0.403601 ( 0.403405)
32
+ SortedSet#delete: 0.008109 0.000005 0.008114 ( 0.008119)
29
33
Insertion:
30
- Array is 15.1x slower than the fastest
31
- Binary is 398.93x slower than the fastest
32
- Narray is the fastest
34
+ Array#<< (append): is 9.55x slower than the fastest
35
+ BinarySearch GEM#insert: is 302.16x slower than the fastest
36
+ Numo::NArray.new + .seq: is the fastest
37
+ SortedSet#add: is 228.03x slower than the fastest
38
+
33
39
Search:
34
- Array is 86.85x slower than the fastest
35
- Binary is the fastest
36
- Narray is 122.61x slower than the fastest
40
+ Array#include?: is 82.9x slower than the fastest
41
+ BinarySearch GEM#include?: is the fastest
42
+ Numo::NArray#eq + .any?: is 118.32x slower than the fastest
43
+ Array#bsearch (std lib): is 2.29x slower than the fastest
44
+
37
45
Deletion:
38
- Array is 58.52x slower than the fastest
39
- Binary is the fastest
40
- Narray is 49.09x slower than the fastest
46
+ Array#delete: is 58.26x slower than the fastest
47
+ BinarySearch GEM#delete: is the fastest
48
+ Numo::NArray delete (mask): is 49.81x slower than the fastest
49
+ SortedSet#delete: is 1.0x slower than the fastest
50
+
41
51
42
52
Benchmarking with 100,000 elements:
43
- user system total real
44
- Array insert: 0.003449 0.000000 0.003449 ( 0.003449)
45
- BinarySearch insert: 0.089313 0.000000 0.089313 ( 0.089320)
46
- NArray insert: 0.000095 0.000000 0.000095 ( 0.000095)
47
- Array search: 15.813410 0.002981 15.816391 ( 15.815585)
48
- BinarySearch search: 0.013462 0.000002 0.013464 ( 0.013466)
49
- NArray search: 18.734754 0.001999 18.736753 ( 18.737876)
50
- Array delete: 47.327969 0.000001 47.327970 ( 47.332518)
51
- BinarySearch delete: 0.042072 0.000001 0.042073 ( 0.042075)
52
- NArray delete: 29.808121 3.051711 32.859832 ( 32.851348)
53
+ user system total real
54
+ Array#<< (append): 0.003539 0.000022 0.003561 ( 0.003571)
55
+ BinarySearch GEM#insert: 0.085730 0.004032 0.089762 ( 0.089782)
56
+ Numo::NArray.new + .seq: 0.000109 0.000004 0.000113 ( 0.000095)
57
+ SortedSet#add: 0.060403 0.000000 0.060403 ( 0.060411)
58
+ Array#include?: 16.131343 0.002956 16.134299 ( 16.133787)
59
+ BinarySearch GEM#include?: 0.013607 0.000002 0.013609 ( 0.013611)
60
+ Numo::NArray#eq + .any?: 18.948453 0.007996 18.956449 ( 18.957555)
61
+ Array#bsearch (std lib): 0.048986 0.000000 0.048986 ( 0.048997)
62
+ Array#delete: 47.501618 0.001000 47.502618 ( 47.508824)
63
+ BinarySearch GEM#delete: 0.043180 0.000001 0.043181 ( 0.043194)
64
+ Numo::NArray delete (mask): 29.937312 2.154682 32.091994 ( 32.080060)
65
+ SortedSet#delete: 0.100403 0.000000 0.100403 ( 0.100697)
53
66
Insertion:
54
- Array is 36.49x slower than the fastest
55
- Binary is 944.99x slower than the fastest
56
- Narray is the fastest
67
+ Array#<< (append): is 37.69x slower than the fastest
68
+ BinarySearch GEM#insert: is 947.56x slower than the fastest
69
+ Numo::NArray.new + .seq: is the fastest
70
+ SortedSet#add: is 637.58x slower than the fastest
71
+
57
72
Search:
58
- Array is 1174.52x slower than the fastest
59
- Binary is the fastest
60
- Narray is 1391.54x slower than the fastest
73
+ Array#include?: is 1185.37x slower than the fastest
74
+ BinarySearch GEM#include?: is the fastest
75
+ Numo::NArray#eq + .any?: is 1392.84x slower than the fastest
76
+ Array#bsearch (std lib): is 3.6x slower than the fastest
77
+
61
78
Deletion:
62
- Array is 1124.94x slower than the fastest
63
- Binary is the fastest
64
- Narray is 780.77x slower than the fastest
79
+ Array#delete: is 1099.89x slower than the fastest
80
+ BinarySearch GEM#delete: is the fastest
81
+ Numo::NArray delete (mask): is 742.7x slower than the fastest
82
+ SortedSet#delete: is 2.33x slower than the fastest
65
83
` ` `
66
84
67
85
# # Installation 💻
0 commit comments