Skip to content

Commit 835d97a

Browse files
authored
Merge pull request #384 from panorama-ed/more-benchmarks
Add `short_circu_it` to benchmarks and remove unused benchmarking code
2 parents 7b0a6b4 + 09ac470 commit 835d97a

File tree

4 files changed

+27
-52
lines changed

4 files changed

+27
-52
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ _Breaking changes:_
1818

1919
- Updated official test coverage to support Ruby 3.4 [[#335](https://github.com/panorama-ed/memo_wise/pull/335)]
2020
- Updated `memery` gem version to 1.7.0 in benchmarks [[#380](https://github.com/panorama-ed/memo_wise/pull/380)]
21+
- Added `short_circu_it` gem to benchmarks [[#384](https://github.com/panorama-ed/memo_wise/pull/384)]
2122

2223
## [v1.11.0](https://github.com/panorama-ed/memo_wise/compare/v1.10.0...v1.11.0)
2324

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,17 @@ Benchmarks are run in GitHub Actions, and the tables below are updated with ever
116116

117117
Results using Ruby 3.4.3:
118118

119-
|Method arguments|`alt_memery` (2.1.0)|`dry-core`\* (1.1.0)|`memery` (1.7.0)|`memoist3` (1.0.0)|
120-
|--|--|--|--|--|
121-
|`()` (none)|12.22x|0.58x|3.41x|2.80x|
122-
|`(a)`|9.31x|0.98x|3.81x|15.03x|
123-
|`(a, b)`|7.30x|0.83x|2.97x|11.88x|
124-
|`(a:)`|14.64x|0.97x|6.71x|19.72x|
125-
|`(a:, b:)`|12.05x|0.85x|5.64x|20.57x|
126-
|`(a, b:)`|12.06x|0.86x|5.57x|16.37x|
127-
|`(a, *args)`|1.93x|0.72x|0.77x|3.04x|
128-
|`(a:, **kwargs)`|2.57x|0.65x|1.14x|4.40x|
129-
|`(a, *args, b:, **kwargs)`|1.75x|0.62x|0.88x|2.98x|
119+
|Method arguments|`alt_memery` (2.1.0)|`dry-core`\* (1.1.0)|`memery` (1.7.0)|`memoist3` (1.0.0)|`short_circu_it` (0.29.3)|
120+
|--|--|--|--|--|--|
121+
|`()` (none)|11.98x|0.59x|3.44x|2.86x|18.45x|
122+
|`(a)`|8.85x|0.92x|3.59x|14.10x|13.11x|
123+
|`(a, b)`|7.35x|0.83x|2.98x|11.70x|10.75x|
124+
|`(a:)`|13.53x|0.90x|6.42x|18.35x|11.86x|
125+
|`(a:, b:)`|12.30x|0.85x|5.75x|20.62x|10.57x|
126+
|`(a, b:)`|11.53x|0.80x|5.39x|15.38x|9.96x|
127+
|`(a, *args)`|1.88x|0.70x|0.75x|2.98x|2.68x|
128+
|`(a:, **kwargs)`|2.65x|0.72x|1.18x|4.43x|2.26x|
129+
|`(a, *args, b:, **kwargs)`|1.78x|0.66x|0.89x|3.02x|1.52x|
130130

131131
\* `dry-core`
132132
[may cause incorrect behavior caused by hash collisions](https://github.com/dry-rb/dry-core/issues/63).
@@ -139,7 +139,8 @@ $ bundle install
139139
$ bundle exec ruby benchmarks.rb
140140
```
141141

142-
If your results differ from what's posted here,
142+
If your results differ from what's posted here, or if there's another gem we
143+
should be benchmarking,
143144
[let us know](https://github.com/panorama-ed/memo_wise/issues/new)!
144145

145146
## Thread Safety

benchmarks/Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ gem "gem_bench", "2.0.5"
1212
# NOTE: Regarding `require: false` below
1313
# 1. GitHub version of MemoWise and the local source of MemoWise share a namespace
1414
# 2. memery & alt_memery share the namespace Memery
15-
# 3. memoist & memoist3 share the namespace Memoist, and also share a load path for their version.rb files.
1615
# This means we must `require: false` in `benchmarks/Gemfile` all, or all but one, of each of these duplicates,
1716
# or we take care to only load them in discrete Ruby versions,
1817
# to avoid a namespace collision before re-namespacing duplicates
1918
gem "alt_memery", "2.1.0", require: false
2019
gem "dry-core", "1.1.0"
2120
gem "memery", "1.7.0"
22-
gem "memoist3", "1.0.0", require: false
21+
gem "memoist3", "1.0.0"
22+
gem "short_circu_it", "0.29.3"
2323

2424
gem "memo_wise", github: "panorama-ed/memo_wise", branch: "main", require: false

benchmarks/benchmarks.rb

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
# 1. GitHub version of MemoWise and the local source of MemoWise share a namespace
1313
# 2. memery & alt_memery share the namespace Memery
14-
# 3. memoist & memoist3 share the namespace Memoist, and also share a load path for their version.rb files.
1514
# This means we must `require: false` in `benchmarks/Gemfile` all, or all but one, of each of these duplicates,
1615
# or we take care to only load them in discrete Ruby versions,
1716
# to avoid a namespace collision before re-namespacing duplicates
@@ -38,27 +37,7 @@
3837
activation_code: "include AltMemery",
3938
memoization_method: :memoize,
4039
},
41-
),
42-
GemBench::Jersey.new(
43-
gem_name: "memoist3",
44-
trades: {
45-
"Memoist" => "MemoistThree"
46-
},
47-
metadata: {
48-
activation_code: "extend MemoistThree",
49-
memoization_method: :memoize,
50-
},
51-
),
52-
GemBench::Jersey.new(
53-
gem_name: "memoist",
54-
trades: {
55-
"Memoist" => "MemoistOne"
56-
},
57-
metadata: {
58-
activation_code: "extend MemoistOne",
59-
memoization_method: :memoize,
60-
},
61-
),
40+
)
6241
].each(&:doff_and_don) # Copies, re-namespaces, and requires each gem.
6342

6443
# We've already installed the `memo_wise` version on the `main` branch from GitHub in the
@@ -67,17 +46,12 @@
6746
# this branch against it.
6847
require_relative "../lib/memo_wise"
6948

70-
# Some gems do not yet work in Ruby 3 so we only require them if they're loaded
71-
# in the Gemfile. Gems re-namespaced by GemBench::Jersey will have already been loaded by now.
72-
%w[memery memoized memoizer ddmemoize dry-core].
73-
each { |gem| require gem if Gem.loaded_specs.key?(gem) }
74-
75-
# Some Gems Have Modules Which Need To Be Required Manually:
76-
require "dry/core/memoizable" if Gem.loaded_specs.key?("dry-core")
77-
78-
# The VERSION constant does not get loaded above for these gems.
79-
%w[memoized memoizer].
80-
each { |gem| require "#{gem}/version" if Gem.loaded_specs.key?(gem) }
49+
# Load gems that haven't been already loaded by GemBench::Jersey.
50+
require "dry-core"
51+
require "dry/core/memoizable"
52+
require "memery"
53+
require "memoist"
54+
require "short_circu_it"
8155

8256
class BenchmarkSuiteWithoutGC
8357
def warming(*)
@@ -122,11 +96,10 @@ def benchmark_name
12296
end
12397
benchmarked_gems.push(
12498
BenchmarkGem.new(MemoWise, "prepend MemoWise", :memo_wise, LOCAL_BENCHMARK_NAME),
125-
(BenchmarkGem.new(DDMemoize, "DDMemoize.activate(self)", :memoize, "ddmemoize") if defined?(DDMemoize)),
126-
(BenchmarkGem.new(Dry::Core, "include Dry::Core::Memoizable", :memoize, "dry-core") if defined?(Dry::Core)),
127-
(BenchmarkGem.new(Memery, "include Memery", :memoize, "memery") if defined?(Memery)),
128-
(BenchmarkGem.new(Memoized, "include Memoized", :memoize, "memoized") if defined?(Memoized)),
129-
(BenchmarkGem.new(Memoizer, "include Memoizer", :memoize, "memoizer") if defined?(Memoizer))
99+
BenchmarkGem.new(Dry::Core, "include Dry::Core::Memoizable", :memoize, "dry-core"),
100+
BenchmarkGem.new(Memery, "include Memery", :memoize, "memery"),
101+
BenchmarkGem.new(Memoist, "extend Memoist", :memoize, "memoist3"),
102+
BenchmarkGem.new(ShortCircuIt, "include ShortCircuIt", :memoize, "short_circu_it")
130103
)
131104
BENCHMARK_GEMS = benchmarked_gems.compact.shuffle
132105

0 commit comments

Comments
 (0)