minting 1.1.0 → 1.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be78b384415345ebacec84c0fc7194c9cb5e8ae2c3f601db5871822987f7e95c
4
- data.tar.gz: 0c852f37bca70dc4af732b824daca634a5b253d4497a10273cc9d041ccf327aa
3
+ metadata.gz: 9506e71f742812607fef378d4df90eaea6d2457f0d818b55b6e06b6167fa6876
4
+ data.tar.gz: 99b200de879dfb9ed4eaec21b02067a886c01d48116fcb669ca70b5dbf314264
5
5
  SHA512:
6
- metadata.gz: 6e13eed34f93beb1a1e26cf89a89fb89a57a06529225610d8cc153c6eae28823368b47a993446e2e4deb3df30cecf31800253a7c55dd070bd6dcb074f615fb91
7
- data.tar.gz: 8e2f204fbd592e93f143ed8756548d2013e909bca37d32a2fa70f41c070a3ede1946f668097faf49822a1e5e9df27cc9cf7865208faa94df47c310e06d96cd24
6
+ metadata.gz: 01b120551584f7f6327f2db19731367dd091bfb3e7b9db91d98cd2ff0b7e1db41d4c190acc66d8cd611fe7689ddb8872b89bebe9db6506e267df121c60fbe6f1
7
+ data.tar.gz: 8cc6a7ffc780a555276298432de7c2929c5ffddadc4fc28b379a8c58245b70672a777e610e464b6ea485583a8b65eb7463b37e29ff422b9e065ecd1f565cb85a
data/README.md CHANGED
@@ -105,15 +105,15 @@ ten.allocate([1, 2, 3]) #=> [[USD 1.67], [USD 3.33], [USD 5.00]]
105
105
 
106
106
  ## API notes
107
107
 
108
- **Module names** — Require the `minting` gem; the public API lives under `Mint` (the gem module is `Minting::VERSION`).
108
+ **Module names** — Require the `minting` gem; the public API lives under `Mint`.
109
109
 
110
- **Exact amounts** — Amounts are stored as `Rational` and rounded to the currency subunit. Prefer rationals or decimal strings for exact literals (`Mint.money(1999/100r, 'USD')`, `'19.99'.to_r`) instead of binary floats when precision matters.
110
+ **Exact amounts** — Amounts are stored as `Rational` and rounded to the currency subunit.
111
111
 
112
112
  **Refinements** — `10.dollars` and similar helpers require `using Mint` in the current scope (see Usage above).
113
113
 
114
114
  **Division** — `money / 5` returns new `Money`; `money / other_money` returns a numeric ratio, not money.
115
115
 
116
- **Zero equality** — `Mint.money(0, 'USD') == Mint.money(0, 'EUR')` is intentionally `true`. Non-zero amounts must match currency and value.
116
+ **Zero equality** — Any zero amount is considered equal across currencies and to numeric zero `Mint.money(0, 'USD') == Mint.money(0, 'EUR')` is intentionally `true`. Non-zero amounts must match currency and value.
117
117
 
118
118
  **Custom currencies** — `Mint.register_currency` returns the existing entry if the code is already registered; use `register_currency!` to detect duplicates.
119
119
 
@@ -192,11 +192,6 @@ This gem includes a performance suite under `test/performance`:
192
192
  - Memory and GC pressure tests
193
193
  - Competitive benchmarks vs `money` gem
194
194
 
195
- On a typical machine, reference numbers are:
196
-
197
- - Money creation: ~1.6M ops/sec
198
- - Addition: ~1.7M ops/sec
199
-
200
195
  Run locally:
201
196
 
202
197
  ```bash
@@ -210,6 +205,49 @@ BENCH=true rake bench:competitive
210
205
  rake bench:regression
211
206
  ```
212
207
 
208
+ ## Benchmark Summary: Minting vs Money Gem
209
+
210
+ Generated by Qwen from the latest benchmark run on Ruby 4.0.1. - 2026-05-30
211
+
212
+ ### Key Takeaways
213
+
214
+ - **Mint is consistently faster** than the Money gem across all measured operations.
215
+ - **Mint is 2.28x faster** in the 50,000-transaction simulation.
216
+ - **Mint object creation is 2.76x faster** than `Money.from_amount`.
217
+ - In formatting and conversion, Mint is often **10+x **.
218
+ - Mint’s performance advantage is especially strong for numeric conversion, string formatting, comparisons, and high-volume transaction loops.
219
+
220
+ ### Performance Highlights
221
+
222
+ | Category | Mint | Money | Approx. Ratio |
223
+ | --- | --- | --- | --- |
224
+ | High-volume transactions | 195,412 ops/sec | 85,882 ops/sec | 2.28x faster |
225
+ | `Mint.money` creation | 1.14M ops/sec | — | 2.76x faster than `Money.from_amount` |
226
+ | `some.dollars` creation | 990k ops/sec | — | 1.15x faster than `Mint.money` |
227
+ | `Money.new` creation | — | 715k ops/sec | Mint 1.59x faster |
228
+ | `to_f` formatting | 8.8M–9.3M ops/sec | 0.7M ops/sec | ~12x faster |
229
+ | `to_d` conversion | 2.1M–2.3M ops/sec | 0.73M–0.79M ops/sec | ~3x faster |
230
+ | `to_s` formatting | 300k–420k ops/sec | 109k–132k ops/sec | ~3x faster |
231
+ | `inspect` formatting | ~2.6–2.9M ops/sec | ~1.1–1.16M ops/sec | ~2.5x faster |
232
+ | `to_json` formatting | ~2.0–2.2M ops/sec | ~110k–126k ops/sec | ~17x faster |
233
+ | Currency lookup `Mint.currency('USD')` | 3.82M ops/sec | — | 1.60x faster than `Money::Currency.new` |
234
+ | Currency lookup `Money::Currency.find('USD')` | 3.63M ops/sec | 1.67M ops/sec | 2.29x faster |
235
+ | Addition | 1.11M ops/sec | 0.37M ops/sec | 3.0x faster |
236
+ | Subtraction | 1.11M ops/sec | 0.36M ops/sec | 3.0x faster |
237
+ | Multiplication | 1.28M ops/sec | 0.51M ops/sec | 2.5x faster |
238
+ | Division | 1.04M ops/sec | 0.37M ops/sec | 2.8x faster |
239
+ | Ratio division | 2.94M ops/sec | 0.39M ops/sec | 7.6x faster |
240
+ | Comparison (`==`, `<`, `>`) | 2.5M–4.1M ops/sec | 0.35M–0.38M ops/sec | 7x–10x faster |
241
+ | Allocation (`Mint.allocate`) | 279k ops/sec | 146k ops/sec | 1.9x faster |
242
+ | Split (`Mint.split`) | 215k ops/sec | 85k ops/sec | 3.3x faster |
243
+
244
+ ### Commands Used
245
+
246
+ ```sh
247
+ BENCH=true bundle exec ruby -Ilib:test -r ./test/test_helper.rb test/performance/competitive_performance_benchmark.rb
248
+ BENCH=true bundle exec ruby -Ilib:test -r ./test/test_helper.rb test/performance/competitive_memory_benchmark.rb
249
+ ```
250
+
213
251
  ## License
214
252
 
215
253
  MIT
data/Rakefile CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rubocop/rake_task'
3
3
  require 'rake/testtask'
4
+ require 'yard'
4
5
 
5
- CLOBBER.include %w[tmp]
6
+ CLOBBER.include %w[doc tmp .yardoc]
6
7
 
7
8
  Rake::TestTask.new(:test) do |t|
8
9
  t.libs << 'test'
@@ -13,16 +14,16 @@ end
13
14
 
14
15
  Rake::TestTask.new(:bench) do |t|
15
16
  t.libs = %w[lib test]
16
- t.pattern = 'test/**/*_benchmark.rb'
17
+ t.pattern = 'test/performance/*_benchmark.rb'
17
18
  end
18
19
 
19
- # Performance benchmark tasks
20
- Rake::TestTask.new('bench:performance') do |t|
20
+ Rake::TestTask.new('bench:edge') do |t|
21
21
  t.libs = %w[lib test]
22
- t.pattern = 'test/performance/*_benchmark.rb'
22
+ t.pattern = 'test/performance/algorithm_benchmark.rb'
23
23
  t.ruby_opts << '-r test_helper.rb'
24
24
  end
25
25
 
26
+
26
27
  Rake::TestTask.new('bench:regression') do |t|
27
28
  t.libs = %w[lib test]
28
29
  t.pattern = 'test/performance/regression_benchmark.rb'
@@ -31,12 +32,16 @@ end
31
32
 
32
33
  Rake::TestTask.new('bench:competitive') do |t|
33
34
  t.libs = %w[lib test]
34
- t.pattern = 'test/performance/competitive_benchmark.rb'
35
+ t.pattern = 'test/performance/competitive_performance_benchmark.rb'
35
36
  t.ruby_opts << '-r test_helper.rb'
36
37
  end
37
38
 
38
- task 'bench:all' => ['bench', 'bench:performance']
39
-
40
39
  RuboCop::RakeTask.new(:cop)
41
40
 
41
+ YARD::Rake::YardocTask.new do |t|
42
+ t.files = ['lib/**/*.rb'] # optional
43
+ t.options = [] # optional
44
+ t.stats_options = ['--list-undoc'] # optional
45
+ end
46
+
42
47
  task default: :test