fat_table 1.1.0 → 1.1.1

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.
@@ -0,0 +1,238 @@
1
+ #+TITLE: FatTable performance checks
2
+
3
+ * Compare saved results
4
+ Display all recorded before/after pairs without rerunning benchmarks:
5
+
6
+ #+begin_src sh
7
+ scripts/benchmark-compare
8
+ #+end_src
9
+
10
+ Compare a particular pair, including newly recorded JSONL results:
11
+
12
+ #+begin_src sh
13
+ scripts/benchmark-compare benchmark/column-baseline-10000.jsonl benchmark/column-fast-10000.jsonl
14
+ #+end_src
15
+
16
+ The command reports median times, speedup, median allocations, allocation
17
+ reduction, and whether all output digests match. It rejects different
18
+ operation names or workload metadata (including row counts and Ruby versions)
19
+ and exits nonzero if output digests differ. Explicit paths are relative to
20
+ the calling directory; the default pairs work from any directory.
21
+
22
+ These are historical measurements of each individual optimization, not a
23
+ fresh run of the current checkout or a cumulative before/after comparison.
24
+ The formatting/group-lookup pair includes the original raw measurements
25
+ recovered from the initial benchmark run.
26
+ Committing these scripts and data preserves the comparisons after merging.
27
+
28
+ * Transformations and rendering
29
+ Run from the repository root:
30
+
31
+ #+begin_src sh
32
+ scripts/benchmark-formatting
33
+ scripts/benchmark-formatting 10000
34
+ BENCH_GROUP_SIZE=100 scripts/benchmark-formatting 1000
35
+ #+end_src
36
+
37
+ The optional positional argument is the row count (default: 4000).
38
+ The wrapper can also be invoked by absolute path from another directory.
39
+
40
+ The script warms each operation, then records three elapsed-time and
41
+ allocated-object samples. Input construction and result hashing are outside
42
+ the timed portion. The table shows median, minimum, and maximum times in
43
+ milliseconds, plus median allocated-object counts.
44
+
45
+ For raw JSON samples and full result digests, run:
46
+
47
+ #+begin_src sh
48
+ BENCH_ROWS=10000 bundle exec ruby -Ilib benchmark/transform_and_render.rb
49
+ #+end_src
50
+
51
+ Digests allow comparing the same workload across revisions on the same
52
+ Ruby version. Compare medians;
53
+ timings vary with hardware, Ruby, dependencies, and system load.
54
+
55
+ This is a synthetic three-column workload, not a representative byr report.
56
+ By default each input row is its own group for select/where, exercising
57
+ group lookup heavily. Rendering uses an ungrouped table. BENCH_GROUP_SIZE
58
+ changes the transformation workload; a value greater than BENCH_ROWS gives
59
+ a single implicit group.
60
+
61
+ * Join baseline
62
+ Run the separate join workload with a row count per input table:
63
+
64
+ #+begin_src sh
65
+ scripts/benchmark-joins
66
+ scripts/benchmark-joins 100
67
+ BENCH_ROWS=200 bundle exec ruby -Ilib benchmark/joins.rb
68
+ #+end_src
69
+
70
+ The join script defaults to 200 rows per input. The last command emits raw JSON
71
+ samples and output digests. Both tables have two columns, duplicate keys
72
+ (two rows per key), and approximately half their key ranges overlap.
73
+ The benchmark covers natural inner, symbol-based inner, and natural full
74
+ outer joins. It checks complete output rows and ordering against independently
75
+ constructed expected results after warmup and every measured run.
76
+ Setup, validation, output extraction, and hashing are outside timing;
77
+ construction of the joined table is included.
78
+
79
+ Baseline: Ruby 3.4.1, library revision =add96a3=, 2026-11-27. Three samples
80
+ after warmup, medians below. Raw 200-row results are saved in
81
+ =joins-baseline-200.jsonl= for later digest and allocation comparisons.
82
+
83
+ | Operation | 100 rows (ms) | 200 rows (ms) | 200-row allocations | Output rows (200) |
84
+ |---------------+---------------+---------------+---------------------+-------------------|
85
+ | natural_inner | 77.114 | 308.065 | 1629228 | 200 |
86
+ | symbol_inner | 75.238 | 299.941 | 1629232 | 200 |
87
+ | natural_full | 78.467 | 309.386 | 1685852 | 400 |
88
+
89
+ Doubling both inputs approximately quadruples elapsed time in this workload.
90
+ The baseline implementation compared every pair of rows. These synthetic
91
+ results do not measure real byr joins.
92
+
93
+ ** Indexed equality joins [2026-11-27 Fri]
94
+ Natural and symbol-based equality joins now index right-hand rows by join
95
+ keys, preserving their original order within each bucket. Arbitrary string
96
+ conditions, cross joins, and unsupported key classes retain the evaluator
97
+ path. Integer/decimal keys and Date/DateTime keys are normalized for hashing;
98
+ candidate matches are still checked with Ruby's ==.
99
+
100
+ Same 200-row workload and Ruby 3.4.1, three samples after warmup:
101
+
102
+ | Operation | Before (ms) | After (ms) | Speedup | Before allocations | After allocations |
103
+ |---------------+-------------+------------+---------+--------------------+-------------------|
104
+ | natural_inner | 308.065 | 2.801 | 110.0x | 1629228 | 30140 |
105
+ | symbol_inner | 299.941 | 2.807 | 106.9x | 1629232 | 30145 |
106
+ | natural_full | 309.386 | 7.938 | 39.0x | 1685852 | 86764 |
107
+
108
+ All output digests match the saved baseline. Raw samples are in
109
+ =joins-indexed-200.jsonl=. At 1,000 rows per input, median times were
110
+ 14.551 ms, 14.774 ms, and 40.178 ms respectively. These measurements show
111
+ approximately linear growth for this workload; duplicate-heavy joins can
112
+ still produce quadratic output. The index adds memory proportional to input
113
+ rows and key width. Rational and other unusual Numeric keys fall back to
114
+ the original path to preserve their comparison semantics.
115
+
116
+ * Prepared sort keys [2026-11-27 Fri]
117
+ Run the sorting workload separately:
118
+
119
+ #+begin_src sh
120
+ scripts/benchmark-sort 4000
121
+ BENCH_ROWS=4000 bundle exec ruby -Ilib benchmark/sort.rb
122
+ #+end_src
123
+
124
+ Uses a deterministic shuffle of five-column rows with repeated numeric keys,
125
+ strings, dates, and boolean/nil keys. Measures complete table operations,
126
+ including result construction and group boundaries. Expression sorting also
127
+ includes evaluating the expression and creating its additional column.
128
+ Input construction and output hashing are excluded. Each operation warms up
129
+ once before three measured samples; figures below are medians on Ruby 3.4.1.
130
+
131
+ | Operation | Before (ms) | After (ms) | Speedup | Before allocations | After allocations |
132
+ |-----------------+-------------+------------+---------+--------------------+-------------------|
133
+ | numeric_sort | 126.079 | 108.639 | 1.16x | 1311377 | 1170820 |
134
+ | mixed_sort | 167.943 | 116.713 | 1.44x | 1320598 | 1188567 |
135
+ | expression_sort | 385.534 | 378.773 | 1.02x | 3909540 | 3766689 |
136
+
137
+ Baseline library revision: =7ba2e42=. Raw results are saved in
138
+ =sort-baseline-4000.jsonl= and =sort-prepared-4000.jsonl=. Digests of headers,
139
+ complete rows, and group boundaries match for every operation. The small
140
+ expression-sort timing difference may be normal run-to-run variation.
141
+
142
+ Comparison keys and boolean normalization are now prepared once per row;
143
+ grouping reuses the original unnormalized keys. This reduces temporary
144
+ allocations during comparisons but retains key arrays for the duration of
145
+ the sort, using memory proportional to rows times key count. Stable ties,
146
+ mixed directions, and nil ordering are preserved. These are synthetic
147
+ results, not measurements of a byr report.
148
+
149
+ * Direct column insertion [2026-11-27 Fri]
150
+ Run row insertion at three table widths:
151
+
152
+ #+begin_src sh
153
+ scripts/benchmark-insertion 1000
154
+ BENCH_ROWS=1000 bundle exec ruby -Ilib benchmark/insertion.rb
155
+ #+end_src
156
+
157
+ The default is 1,000 rows. Input hashes contain integer values and are built
158
+ before timing. Each measured operation constructs a fresh table and inserts
159
+ all rows with add_row. Output extraction and hashing are excluded. The three
160
+ widths exercise column lookup costs; string parsing and real byr workloads
161
+ will have different proportions of conversion and lookup work.
162
+
163
+ Ruby 3.4.1, baseline revision =8a4a3e8=; medians of three samples after warmup:
164
+
165
+ | Columns | Before (ms) | After (ms) | Speedup | Before allocations | After allocations |
166
+ |---------+-------------+------------+---------+--------------------+-------------------|
167
+ | 4 | 18.391 | 5.630 | 3.27x | 200169 | 57169 |
168
+ | 16 | 181.886 | 23.577 | 7.71x | 2030625 | 213625 |
169
+ | 64 | 2468.338 | 92.086 | 26.80x | 28073449 | 840449 |
170
+
171
+ Raw samples are in =insertion-baseline-1000.jsonl= and
172
+ =insertion-direct-1000.jsonl=. All digests of headers, rows, and boundaries
173
+ match. add_row now traverses destination columns directly, eliminating a
174
+ linear column-name search for each cell. Column conversion, new-column
175
+ backfilling, and missing values still use the existing paths. There is no
176
+ persistent column cache to invalidate when the table changes.
177
+
178
+ * Column append fast paths [2026-11-27 Fri]
179
+ Run the isolated column workload:
180
+
181
+ #+begin_src sh
182
+ scripts/benchmark-column 10000
183
+ BENCH_ROWS=10000 bundle exec ruby -Ilib benchmark/column.rb
184
+ #+end_src
185
+
186
+ The default is 10,000 values. Each operation builds a fresh column with an
187
+ established type, using prebuilt values. Numeric input alternates integers
188
+ and BigDecimals; tolerant numeric input alternates integers and an
189
+ unparseable string. Setup and output hashing are excluded. Column creation
190
+ and all appends are included. Medians of three samples after warmup on
191
+ Ruby 3.4.1, baseline revision =8cf529d=:
192
+
193
+ | Operation | Before (ms) | After (ms) | Speedup |
194
+ |------------------+-------------+------------+---------|
195
+ | native_numeric | 1.559 | 0.737 | 2.12x |
196
+ | strings | 1.685 | 0.629 | 2.68x |
197
+ | native_dates | 1.450 | 0.546 | 2.66x |
198
+ | native_booleans | 1.517 | 0.611 | 2.48x |
199
+ | tolerant_numeric | 13.473 | 7.839 | 1.72x |
200
+
201
+ Output digests include column type and all items and match the baseline.
202
+ Raw samples are in =column-baseline-10000.jsonl= and
203
+ =column-fast-10000.jsonl=. Native-value cases allocate four objects in each
204
+ measured run before and after; their gains come from reduced dispatch and
205
+ type checks. Tolerant numeric allocations fall from 90,006 to 65,006 as
206
+ ordinary failed conversions no longer raise and re-raise exceptions.
207
+
208
+ Established string columns skip redundant type inference; compatible native
209
+ numeric, date, and boolean values skip conversion. Floats still promote to
210
+ BigDecimal, open columns still infer their type, and strict conversion errors
211
+ retain their messages. These short isolated measurements do not imply the
212
+ same speedups for complete table operations or byr reports.
213
+
214
+ * Initial measurements [2026-11-27 Fri]
215
+ Local Ruby 3.4.1, 4,000 rows, three measured runs after warmup. Baseline
216
+ measured before the optimizations branch edits. All result digests matched.
217
+ Original raw samples are preserved in =formatting-baseline-4000.jsonl= and
218
+ =formatting-buffer-4000.jsonl= and included in =scripts/benchmark-compare=.
219
+ Both runs used the same original harness with Benchmark.realtime, one group
220
+ per row for transformations, and ungrouped rendering. Input construction was
221
+ outside timing. These older files omit Ruby and group-size metadata.
222
+
223
+ | Operation | Before (s) | After (s) | Speedup |
224
+ |------------------------+------------+-----------+---------|
225
+ | select with group expr | 0.2727 | 0.0724 | 3.77x |
226
+ | where with group expr | 0.2387 | 0.0451 | 5.30x |
227
+ | text rendering | 0.0979 | 0.0156 | 6.28x |
228
+
229
+ This table now uses the recovered original before/after samples. The prior
230
+ summary used a follow-up run of the maintained harness for its after values,
231
+ which gave the slightly different 3.72x, 5.59x, and 6.20x figures.
232
+
233
+ Changes measured: a forward group cursor in select/where instead of a
234
+ fresh boundary scan per row; appending report fragments to an owned mutable
235
+ string instead of copying the accumulated output at every append.
236
+
237
+ These figures illustrate the targeted workloads, not general application
238
+ speedups. Profile actual byr reports before choosing subsequent changes.
@@ -0,0 +1,5 @@
1
+ {"name":"native_numeric","rows":10000,"ruby":"3.4.1","samples":[{"seconds":0.0015968739753589034,"allocations":10,"digest":"bbf9a497737cef34d393c3b92275837509cfb58d7d828eade7e79924b2c4a64b"},{"seconds":0.0015591969713568687,"allocations":4,"digest":"bbf9a497737cef34d393c3b92275837509cfb58d7d828eade7e79924b2c4a64b"},{"seconds":0.0014988160692155361,"allocations":4,"digest":"bbf9a497737cef34d393c3b92275837509cfb58d7d828eade7e79924b2c4a64b"}]}
2
+ {"name":"strings","rows":10000,"ruby":"3.4.1","samples":[{"seconds":0.0016816670540720224,"allocations":4,"digest":"6ff52b6fd23628c63cedb24764bbd37e9e925f76b4824501a76f9051d70f61e1"},{"seconds":0.001684688962996006,"allocations":4,"digest":"6ff52b6fd23628c63cedb24764bbd37e9e925f76b4824501a76f9051d70f61e1"},{"seconds":0.0017443998949602246,"allocations":4,"digest":"6ff52b6fd23628c63cedb24764bbd37e9e925f76b4824501a76f9051d70f61e1"}]}
3
+ {"name":"native_dates","rows":10000,"ruby":"3.4.1","samples":[{"seconds":0.0014501750702038407,"allocations":4,"digest":"83be8aa3398ff2f47d1b304aca24090c443a6b49a6de72806367aa33fde44a57"},{"seconds":0.0014496109215542674,"allocations":4,"digest":"83be8aa3398ff2f47d1b304aca24090c443a6b49a6de72806367aa33fde44a57"},{"seconds":0.0014552560169249773,"allocations":4,"digest":"83be8aa3398ff2f47d1b304aca24090c443a6b49a6de72806367aa33fde44a57"}]}
4
+ {"name":"native_booleans","rows":10000,"ruby":"3.4.1","samples":[{"seconds":0.0015173570718616247,"allocations":4,"digest":"c1de9d48f6e505dc7c35259a89c61a827d53c7760ca6c2d368cea7c48fa60391"},{"seconds":0.0015173510182648897,"allocations":4,"digest":"c1de9d48f6e505dc7c35259a89c61a827d53c7760ca6c2d368cea7c48fa60391"},{"seconds":0.0014894340420141816,"allocations":4,"digest":"c1de9d48f6e505dc7c35259a89c61a827d53c7760ca6c2d368cea7c48fa60391"}]}
5
+ {"name":"tolerant_numeric","rows":10000,"ruby":"3.4.1","samples":[{"seconds":0.013473052997142076,"allocations":90006,"digest":"7b1f7aa05cdb0cd272e361f3b0422149be4f347e2b132590bd58c93b98bcbc88"},{"seconds":0.013102341094054282,"allocations":90006,"digest":"7b1f7aa05cdb0cd272e361f3b0422149be4f347e2b132590bd58c93b98bcbc88"},{"seconds":0.013544060057029128,"allocations":90006,"digest":"7b1f7aa05cdb0cd272e361f3b0422149be4f347e2b132590bd58c93b98bcbc88"}]}
@@ -0,0 +1,5 @@
1
+ {"name":"native_numeric","rows":10000,"ruby":"3.4.1","samples":[{"seconds":0.0007366329664364457,"allocations":10,"digest":"bbf9a497737cef34d393c3b92275837509cfb58d7d828eade7e79924b2c4a64b"},{"seconds":0.0007505279500037432,"allocations":4,"digest":"bbf9a497737cef34d393c3b92275837509cfb58d7d828eade7e79924b2c4a64b"},{"seconds":0.0007168640149757266,"allocations":4,"digest":"bbf9a497737cef34d393c3b92275837509cfb58d7d828eade7e79924b2c4a64b"}]}
2
+ {"name":"strings","rows":10000,"ruby":"3.4.1","samples":[{"seconds":0.0006147510139271617,"allocations":4,"digest":"6ff52b6fd23628c63cedb24764bbd37e9e925f76b4824501a76f9051d70f61e1"},{"seconds":0.0006630429998040199,"allocations":4,"digest":"6ff52b6fd23628c63cedb24764bbd37e9e925f76b4824501a76f9051d70f61e1"},{"seconds":0.0006290849996730685,"allocations":4,"digest":"6ff52b6fd23628c63cedb24764bbd37e9e925f76b4824501a76f9051d70f61e1"}]}
3
+ {"name":"native_dates","rows":10000,"ruby":"3.4.1","samples":[{"seconds":0.0005457149818539619,"allocations":4,"digest":"83be8aa3398ff2f47d1b304aca24090c443a6b49a6de72806367aa33fde44a57"},{"seconds":0.000587229966185987,"allocations":4,"digest":"83be8aa3398ff2f47d1b304aca24090c443a6b49a6de72806367aa33fde44a57"},{"seconds":0.0005454130005091429,"allocations":4,"digest":"83be8aa3398ff2f47d1b304aca24090c443a6b49a6de72806367aa33fde44a57"}]}
4
+ {"name":"native_booleans","rows":10000,"ruby":"3.4.1","samples":[{"seconds":0.0006036589620634913,"allocations":4,"digest":"c1de9d48f6e505dc7c35259a89c61a827d53c7760ca6c2d368cea7c48fa60391"},{"seconds":0.0006273130420595407,"allocations":4,"digest":"c1de9d48f6e505dc7c35259a89c61a827d53c7760ca6c2d368cea7c48fa60391"},{"seconds":0.0006110490066930652,"allocations":4,"digest":"c1de9d48f6e505dc7c35259a89c61a827d53c7760ca6c2d368cea7c48fa60391"}]}
5
+ {"name":"tolerant_numeric","rows":10000,"ruby":"3.4.1","samples":[{"seconds":0.007838726043701172,"allocations":65006,"digest":"7b1f7aa05cdb0cd272e361f3b0422149be4f347e2b132590bd58c93b98bcbc88"},{"seconds":0.007895160932093859,"allocations":65006,"digest":"7b1f7aa05cdb0cd272e361f3b0422149be4f347e2b132590bd58c93b98bcbc88"},{"seconds":0.0076921769650653005,"allocations":65006,"digest":"7b1f7aa05cdb0cd272e361f3b0422149be4f347e2b132590bd58c93b98bcbc88"}]}
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run with: scripts/benchmark-column 10000
4
+ require 'fat_table'
5
+ require 'digest'
6
+ require 'json'
7
+
8
+ row_count = Integer(ENV.fetch('BENCH_ROWS', '10000'))
9
+ raise ArgumentError, 'row count must be positive' unless row_count.positive?
10
+
11
+ numeric_values = Array.new(row_count) { |i| i.even? ? i : BigDecimal(i.to_s) }
12
+ string_values = Array.new(row_count) { |i| "Item #{i}" }
13
+ tolerant_values = Array.new(row_count) { |i| i.even? ? i : 'unknown' }
14
+ date_values = Array.new(row_count) { |i| Date.new(2026, 1, 1) + i % 28 }
15
+ boolean_values = Array.new(row_count, &:even?)
16
+ operations = {
17
+ native_numeric: -> { FatTable::Column.new(header: :value, type: 'Numeric', items: numeric_values) },
18
+ strings: -> { FatTable::Column.new(header: :value, type: 'String', items: string_values) },
19
+ native_dates: -> { FatTable::Column.new(header: :value, type: 'DateTime', items: date_values) },
20
+ native_booleans: -> { FatTable::Column.new(header: :value, type: 'Boolean', items: boolean_values) },
21
+ tolerant_numeric: lambda {
22
+ FatTable::Column.new(header: :value, type: 'Numeric', tolerant: true, items: tolerant_values)
23
+ },
24
+ }
25
+
26
+ text_output = ARGV.include?('--text')
27
+ if text_output
28
+ puts "FatTable column append benchmarks — Ruby #{RUBY_VERSION}"
29
+ puts "Rows: #{row_count} | 3 samples after warmup"
30
+ puts
31
+ printf "% -20s %12s %12s %12s %14s\n", 'Operation', 'Median (ms)', 'Min (ms)', 'Max (ms)', 'Allocations'
32
+ puts '-' * 74
33
+ end
34
+
35
+ operations.each do |name, operation|
36
+ operation.call # Warm up before measuring; input construction is excluded.
37
+ samples = Array.new(3) do
38
+ GC.start
39
+ before = GC.stat(:total_allocated_objects)
40
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
41
+ result = operation.call
42
+ elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
43
+ allocated = GC.stat(:total_allocated_objects) - before
44
+ output = [result.type, result.items]
45
+ { seconds: elapsed, allocations: allocated, digest: Digest::SHA256.hexdigest(Marshal.dump(output)) }
46
+ end
47
+ if text_output
48
+ times = samples.map { |sample| sample[:seconds] * 1000 }.sort
49
+ allocations = samples.map { |sample| sample[:allocations] }.sort
50
+ printf "% -20s %12.3f %12.3f %12.3f %14d\n", name, times[1], times.first, times.last, allocations[1]
51
+ else
52
+ puts JSON.generate(name: name, rows: row_count, ruby: RUBY_VERSION, samples: samples)
53
+ end
54
+ end
55
+
56
+ if text_output
57
+ puts "\nAllocations are median object counts. Input data construction and hashing are excluded."
58
+ puts 'Column construction is included.'
59
+ end
@@ -0,0 +1,3 @@
1
+ {"name":"select_groups","rows":4000,"samples":[{"seconds":0.27266682405024767,"allocations":620253,"digest":"cb3603a1d24f53033df96126ed6c70baa53f3cb0acaad903bc11f50523ae70b2"},{"seconds":0.27266899996902794,"allocations":620236,"digest":"cb3603a1d24f53033df96126ed6c70baa53f3cb0acaad903bc11f50523ae70b2"},{"seconds":0.28031139203812927,"allocations":620246,"digest":"cb3603a1d24f53033df96126ed6c70baa53f3cb0acaad903bc11f50523ae70b2"}]}
2
+ {"name":"where_groups","rows":4000,"samples":[{"seconds":0.23871085094287992,"allocations":352240,"digest":"242037826801928776303d16765cb8aded844ceff8a00337bc44ac3e5fc4ab92"},{"seconds":0.2353115420555696,"allocations":352240,"digest":"242037826801928776303d16765cb8aded844ceff8a00337bc44ac3e5fc4ab92"},{"seconds":0.23912237398326397,"allocations":352240,"digest":"242037826801928776303d16765cb8aded844ceff8a00337bc44ac3e5fc4ab92"}]}
3
+ {"name":"text_report","rows":4000,"samples":[{"seconds":0.10189100890420377,"allocations":164285,"digest":"ea088f34aafdaaff41a22c995e3a78e0b239b0c9fc0089c0b46fe1900ff9a226"},{"seconds":0.09791955701075494,"allocations":164285,"digest":"ea088f34aafdaaff41a22c995e3a78e0b239b0c9fc0089c0b46fe1900ff9a226"},{"seconds":0.09476961195468903,"allocations":164285,"digest":"ea088f34aafdaaff41a22c995e3a78e0b239b0c9fc0089c0b46fe1900ff9a226"}]}
@@ -0,0 +1,3 @@
1
+ {"name":"select_groups","rows":4000,"samples":[{"seconds":0.07239013002254069,"allocations":612263,"digest":"cb3603a1d24f53033df96126ed6c70baa53f3cb0acaad903bc11f50523ae70b2"},{"seconds":0.07306329999119043,"allocations":612252,"digest":"cb3603a1d24f53033df96126ed6c70baa53f3cb0acaad903bc11f50523ae70b2"},{"seconds":0.07205721002537757,"allocations":612253,"digest":"cb3603a1d24f53033df96126ed6c70baa53f3cb0acaad903bc11f50523ae70b2"}]}
2
+ {"name":"where_groups","rows":4000,"samples":[{"seconds":0.05219972401391715,"allocations":344242,"digest":"242037826801928776303d16765cb8aded844ceff8a00337bc44ac3e5fc4ab92"},{"seconds":0.04507644800469279,"allocations":344241,"digest":"242037826801928776303d16765cb8aded844ceff8a00337bc44ac3e5fc4ab92"},{"seconds":0.042686137021519244,"allocations":344243,"digest":"242037826801928776303d16765cb8aded844ceff8a00337bc44ac3e5fc4ab92"}]}
3
+ {"name":"text_report","rows":4000,"samples":[{"seconds":0.015586058958433568,"allocations":152277,"digest":"ea088f34aafdaaff41a22c995e3a78e0b239b0c9fc0089c0b46fe1900ff9a226"},{"seconds":0.015858466969802976,"allocations":152277,"digest":"ea088f34aafdaaff41a22c995e3a78e0b239b0c9fc0089c0b46fe1900ff9a226"},{"seconds":0.015047636930830777,"allocations":152277,"digest":"ea088f34aafdaaff41a22c995e3a78e0b239b0c9fc0089c0b46fe1900ff9a226"}]}
@@ -0,0 +1,3 @@
1
+ {"name":"insert_4_columns","rows":1000,"ruby":"3.4.1","samples":[{"seconds":0.01822314108721912,"allocations":200175,"digest":"f7345f156c4bb34eac1668e9d76cc6d4512b00a702a8a982a38727d9f938b43d"},{"seconds":0.018391447025351226,"allocations":200169,"digest":"f7345f156c4bb34eac1668e9d76cc6d4512b00a702a8a982a38727d9f938b43d"},{"seconds":0.018572926986962557,"allocations":200169,"digest":"f7345f156c4bb34eac1668e9d76cc6d4512b00a702a8a982a38727d9f938b43d"}]}
2
+ {"name":"insert_16_columns","rows":1000,"ruby":"3.4.1","samples":[{"seconds":0.1807764950208366,"allocations":2030625,"digest":"c5cb37308eddb2bf2977884cdc803aa4b4f1b4c83169424092fc88f9384cdca0"},{"seconds":0.18188600498251617,"allocations":2030625,"digest":"c5cb37308eddb2bf2977884cdc803aa4b4f1b4c83169424092fc88f9384cdca0"},{"seconds":0.18473395996261388,"allocations":2030625,"digest":"c5cb37308eddb2bf2977884cdc803aa4b4f1b4c83169424092fc88f9384cdca0"}]}
3
+ {"name":"insert_64_columns","rows":1000,"ruby":"3.4.1","samples":[{"seconds":2.4904428210575134,"allocations":28073449,"digest":"9881049a7d5d9df7a5f63dc1460e6ceb56ce49159d23adfb1c5ad353f2fc73d1"},{"seconds":2.4683383950032294,"allocations":28073449,"digest":"9881049a7d5d9df7a5f63dc1460e6ceb56ce49159d23adfb1c5ad353f2fc73d1"},{"seconds":2.454109846963547,"allocations":28073449,"digest":"9881049a7d5d9df7a5f63dc1460e6ceb56ce49159d23adfb1c5ad353f2fc73d1"}]}
@@ -0,0 +1,3 @@
1
+ {"name":"insert_4_columns","rows":1000,"ruby":"3.4.1","samples":[{"seconds":0.0060619390569627285,"allocations":57175,"digest":"f7345f156c4bb34eac1668e9d76cc6d4512b00a702a8a982a38727d9f938b43d"},{"seconds":0.005573834991082549,"allocations":57169,"digest":"f7345f156c4bb34eac1668e9d76cc6d4512b00a702a8a982a38727d9f938b43d"},{"seconds":0.005629641003906727,"allocations":57169,"digest":"f7345f156c4bb34eac1668e9d76cc6d4512b00a702a8a982a38727d9f938b43d"}]}
2
+ {"name":"insert_16_columns","rows":1000,"ruby":"3.4.1","samples":[{"seconds":0.023861209047026932,"allocations":213625,"digest":"c5cb37308eddb2bf2977884cdc803aa4b4f1b4c83169424092fc88f9384cdca0"},{"seconds":0.02357702306471765,"allocations":213625,"digest":"c5cb37308eddb2bf2977884cdc803aa4b4f1b4c83169424092fc88f9384cdca0"},{"seconds":0.023561722016893327,"allocations":213625,"digest":"c5cb37308eddb2bf2977884cdc803aa4b4f1b4c83169424092fc88f9384cdca0"}]}
3
+ {"name":"insert_64_columns","rows":1000,"ruby":"3.4.1","samples":[{"seconds":0.09208613494411111,"allocations":840449,"digest":"9881049a7d5d9df7a5f63dc1460e6ceb56ce49159d23adfb1c5ad353f2fc73d1"},{"seconds":0.09273964399471879,"allocations":840449,"digest":"9881049a7d5d9df7a5f63dc1460e6ceb56ce49159d23adfb1c5ad353f2fc73d1"},{"seconds":0.09014687000308186,"allocations":840449,"digest":"9881049a7d5d9df7a5f63dc1460e6ceb56ce49159d23adfb1c5ad353f2fc73d1"}]}
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run with: scripts/benchmark-insertion 1000
4
+ require 'fat_table'
5
+ require 'digest'
6
+ require 'json'
7
+
8
+ row_count = Integer(ENV.fetch('BENCH_ROWS', '1000'))
9
+ raise ArgumentError, 'row count must be positive' unless row_count.positive?
10
+
11
+ operations = [4, 16, 64].to_h do |width|
12
+ heads = Array.new(width) { |i| "column_#{i}".to_sym }
13
+ data = Array.new(row_count) { |i| heads.to_h { |head| [head, i] } }
14
+ operation = lambda do
15
+ table = FatTable::Table.new(*heads)
16
+ data.each { |row| table.add_row(row) }
17
+ table
18
+ end
19
+ ["insert_#{width}_columns", operation]
20
+ end
21
+
22
+ text_output = ARGV.include?('--text')
23
+ if text_output
24
+ puts "FatTable row insertion benchmarks — Ruby #{RUBY_VERSION}"
25
+ puts "Rows: #{row_count} | 3 samples after warmup"
26
+ puts
27
+ printf "% -20s %12s %12s %12s %14s\n", 'Operation', 'Median (ms)', 'Min (ms)', 'Max (ms)', 'Allocations'
28
+ puts '-' * 74
29
+ end
30
+
31
+ operations.each do |name, operation|
32
+ operation.call # Warm up before measuring; input construction is excluded.
33
+ samples = Array.new(3) do
34
+ GC.start
35
+ before = GC.stat(:total_allocated_objects)
36
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
37
+ result = operation.call
38
+ elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
39
+ allocated = GC.stat(:total_allocated_objects) - before
40
+ output = [result.headers, result.rows, result.boundaries]
41
+ { seconds: elapsed, allocations: allocated, digest: Digest::SHA256.hexdigest(Marshal.dump(output)) }
42
+ end
43
+ if text_output
44
+ times = samples.map { |sample| sample[:seconds] * 1000 }.sort
45
+ allocations = samples.map { |sample| sample[:allocations] }.sort
46
+ printf "% -20s %12.3f %12.3f %12.3f %14d\n", name, times[1], times.first, times.last, allocations[1]
47
+ else
48
+ puts JSON.generate(name: name, rows: row_count, ruby: RUBY_VERSION, samples: samples)
49
+ end
50
+ end
51
+
52
+ if text_output
53
+ puts "\nAllocations are median object counts. Input data construction and hashing are excluded."
54
+ puts 'Table construction is included.'
55
+ end
@@ -0,0 +1,3 @@
1
+ {"name":"natural_inner","rows":200,"output_rows":200,"ruby":"3.4.1","samples":[{"seconds":0.30773086403496563,"allocations":1629234,"digest":"9cf9dee3f241f54cdff7b0d2fe75540142ce77076b69b3ba2754167b30c39208"},{"seconds":0.3093940010294318,"allocations":1629228,"digest":"9cf9dee3f241f54cdff7b0d2fe75540142ce77076b69b3ba2754167b30c39208"},{"seconds":0.30806496704462916,"allocations":1629228,"digest":"9cf9dee3f241f54cdff7b0d2fe75540142ce77076b69b3ba2754167b30c39208"}]}
2
+ {"name":"symbol_inner","rows":200,"output_rows":200,"ruby":"3.4.1","samples":[{"seconds":0.2999405590817332,"allocations":1629232,"digest":"9cf9dee3f241f54cdff7b0d2fe75540142ce77076b69b3ba2754167b30c39208"},{"seconds":0.30230887699872255,"allocations":1629232,"digest":"9cf9dee3f241f54cdff7b0d2fe75540142ce77076b69b3ba2754167b30c39208"},{"seconds":0.29608305904548615,"allocations":1629232,"digest":"9cf9dee3f241f54cdff7b0d2fe75540142ce77076b69b3ba2754167b30c39208"}]}
3
+ {"name":"natural_full","rows":200,"output_rows":400,"ruby":"3.4.1","samples":[{"seconds":0.31011369498446584,"allocations":1685852,"digest":"04649a0a7b891b7a21acdfe3d9d7d2458675d4be772dec22127147730587c63e"},{"seconds":0.3093859169166535,"allocations":1685852,"digest":"04649a0a7b891b7a21acdfe3d9d7d2458675d4be772dec22127147730587c63e"},{"seconds":0.30634311598259956,"allocations":1685852,"digest":"04649a0a7b891b7a21acdfe3d9d7d2458675d4be772dec22127147730587c63e"}]}
@@ -0,0 +1,3 @@
1
+ {"name":"natural_inner","rows":200,"output_rows":200,"ruby":"3.4.1","samples":[{"seconds":0.0028429689118638635,"allocations":30146,"digest":"9cf9dee3f241f54cdff7b0d2fe75540142ce77076b69b3ba2754167b30c39208"},{"seconds":0.0027978719444945455,"allocations":30140,"digest":"9cf9dee3f241f54cdff7b0d2fe75540142ce77076b69b3ba2754167b30c39208"},{"seconds":0.0028013279661536217,"allocations":30140,"digest":"9cf9dee3f241f54cdff7b0d2fe75540142ce77076b69b3ba2754167b30c39208"}]}
2
+ {"name":"symbol_inner","rows":200,"output_rows":200,"ruby":"3.4.1","samples":[{"seconds":0.002877102931961417,"allocations":30145,"digest":"9cf9dee3f241f54cdff7b0d2fe75540142ce77076b69b3ba2754167b30c39208"},{"seconds":0.0028067169478163123,"allocations":30145,"digest":"9cf9dee3f241f54cdff7b0d2fe75540142ce77076b69b3ba2754167b30c39208"},{"seconds":0.0027858701068907976,"allocations":30145,"digest":"9cf9dee3f241f54cdff7b0d2fe75540142ce77076b69b3ba2754167b30c39208"}]}
3
+ {"name":"natural_full","rows":200,"output_rows":400,"ruby":"3.4.1","samples":[{"seconds":0.007969307014718652,"allocations":86764,"digest":"04649a0a7b891b7a21acdfe3d9d7d2458675d4be772dec22127147730587c63e"},{"seconds":0.007937980000860989,"allocations":86764,"digest":"04649a0a7b891b7a21acdfe3d9d7d2458675d4be772dec22127147730587c63e"},{"seconds":0.00788680394180119,"allocations":86764,"digest":"04649a0a7b891b7a21acdfe3d9d7d2458675d4be772dec22127147730587c63e"}]}
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fat_table'
4
+ require 'digest'
5
+ require 'json'
6
+
7
+ row_count = Integer(ENV.fetch('BENCH_ROWS', '200'))
8
+ raise ArgumentError, 'row count must be positive' unless row_count.positive?
9
+
10
+ # Duplicate keys on each side, with partial overlap and unmatched rows.
11
+ # Build expected rows independently, outside the measured operations.
12
+ left_rows = Array.new(row_count) { |i| { id: i / 2, left_value: "Left #{i}" } }
13
+ right_rows = Array.new(row_count) { |i| { id: i / 2 + row_count / 4, right_value: "Right #{i}" } }
14
+ left = FatTable::Table.from_aoh(left_rows)
15
+ right = FatTable::Table.from_aoh(right_rows)
16
+ inner_expected = []
17
+ full_expected = []
18
+ matched_right = {}
19
+ left_rows.each do |left_row|
20
+ matches = right_rows.each_with_index.select { |right_row, _| left_row[:id] == right_row[:id] }
21
+ if matches.empty?
22
+ full_expected << left_row.merge(id_b: nil, right_value: nil)
23
+ else
24
+ matches.each do |right_row, index|
25
+ matched_right[index] = true
26
+ inner_expected << left_row.merge(right_value: right_row[:right_value])
27
+ full_expected << left_row.merge(id_b: right_row[:id], right_value: right_row[:right_value])
28
+ end
29
+ end
30
+ end
31
+ right_rows.each_with_index do |row, index|
32
+ full_expected << {
33
+ id: nil,
34
+ left_value: nil,
35
+ id_b: row[:id],
36
+ right_value: row[:right_value]
37
+ } unless matched_right[index]
38
+ end
39
+
40
+ operations = {
41
+ natural_inner: [-> { left.join(right) }, inner_expected],
42
+ symbol_inner: [-> { left.join(right, :id) }, inner_expected],
43
+ natural_full: [-> { left.full_join(right) }, full_expected],
44
+ }
45
+ text_output = ARGV.include?('--text')
46
+ if text_output
47
+ puts "FatTable join benchmarks — Ruby #{RUBY_VERSION}"
48
+ puts "Rows per input: #{row_count} | Duplicate keys, partial overlap | 3 samples after warmup"
49
+ puts
50
+ printf "%-20s %10s %12s %12s %12s %14s\n",
51
+ 'Operation',
52
+ 'Rows out',
53
+ 'Median (ms)',
54
+ 'Min (ms)',
55
+ 'Max (ms)',
56
+ 'Allocations'
57
+ end
58
+ operations.each do |name, (operation, expected)|
59
+ raise "Unexpected result for #{name}" unless operation.call.rows == expected
60
+
61
+ samples = Array.new(3) do
62
+ GC.start
63
+ before = GC.stat(:total_allocated_objects)
64
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
65
+ result = operation.call
66
+ elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
67
+ allocated = GC.stat(:total_allocated_objects) - before
68
+ output = result.rows
69
+ raise "Unexpected result for #{name}" unless output == expected
70
+
71
+ { seconds: elapsed, allocations: allocated, digest: Digest::SHA256.hexdigest(Marshal.dump(output)) }
72
+ end
73
+ if text_output
74
+ times = samples.map { |sample| sample[:seconds] * 1000 }.sort
75
+ allocations = samples.map { |sample| sample[:allocations] }.sort
76
+ printf "%-20s %10d %12.3f %12.3f %12.3f %14d\n",
77
+ name,
78
+ expected.size,
79
+ times[1],
80
+ times.first,
81
+ times.last,
82
+ allocations[1]
83
+ else
84
+ puts JSON.generate(name: name, rows: row_count, output_rows: expected.size, ruby: RUBY_VERSION, samples: samples)
85
+ end
86
+ end
87
+ puts "\nAllocations are medians. Setup, output verification, and hashing are excluded." if text_output
@@ -0,0 +1,3 @@
1
+ {"name":"numeric_sort","rows":4000,"ruby":"3.4.1","samples":[{"seconds":0.13800247199833393,"allocations":1311383,"digest":"d6281de4e5bb33830179122152cdffa371e09030ba6961162a5d57d0d7fa241d"},{"seconds":0.12607905000913888,"allocations":1311377,"digest":"d6281de4e5bb33830179122152cdffa371e09030ba6961162a5d57d0d7fa241d"},{"seconds":0.12601224204991013,"allocations":1311377,"digest":"d6281de4e5bb33830179122152cdffa371e09030ba6961162a5d57d0d7fa241d"}]}
2
+ {"name":"mixed_sort","rows":4000,"ruby":"3.4.1","samples":[{"seconds":0.16920776199549437,"allocations":1320598,"digest":"c9f80c4d8291acd6aa580fc3b926618601e0b4447d4fe1fc429fcd12ffe03ebe"},{"seconds":0.16651035600807518,"allocations":1320598,"digest":"c9f80c4d8291acd6aa580fc3b926618601e0b4447d4fe1fc429fcd12ffe03ebe"},{"seconds":0.16794329695403576,"allocations":1320598,"digest":"c9f80c4d8291acd6aa580fc3b926618601e0b4447d4fe1fc429fcd12ffe03ebe"}]}
3
+ {"name":"expression_sort","rows":4000,"ruby":"3.4.1","samples":[{"seconds":0.3849134569754824,"allocations":3909540,"digest":"48b1db8b2bb1cc9f2034b6445b3bf7fc90d46b0422760951d156ad4e9407495b"},{"seconds":0.39200271700974554,"allocations":3909540,"digest":"48b1db8b2bb1cc9f2034b6445b3bf7fc90d46b0422760951d156ad4e9407495b"},{"seconds":0.3855343949981034,"allocations":3909540,"digest":"48b1db8b2bb1cc9f2034b6445b3bf7fc90d46b0422760951d156ad4e9407495b"}]}
@@ -0,0 +1,3 @@
1
+ {"name":"numeric_sort","rows":4000,"ruby":"3.4.1","samples":[{"seconds":0.13356487406417727,"allocations":1170826,"digest":"d6281de4e5bb33830179122152cdffa371e09030ba6961162a5d57d0d7fa241d"},{"seconds":0.10855702799744904,"allocations":1170820,"digest":"d6281de4e5bb33830179122152cdffa371e09030ba6961162a5d57d0d7fa241d"},{"seconds":0.10863903700374067,"allocations":1170820,"digest":"d6281de4e5bb33830179122152cdffa371e09030ba6961162a5d57d0d7fa241d"}]}
2
+ {"name":"mixed_sort","rows":4000,"ruby":"3.4.1","samples":[{"seconds":0.11822322790976614,"allocations":1188567,"digest":"c9f80c4d8291acd6aa580fc3b926618601e0b4447d4fe1fc429fcd12ffe03ebe"},{"seconds":0.11615917005110532,"allocations":1188567,"digest":"c9f80c4d8291acd6aa580fc3b926618601e0b4447d4fe1fc429fcd12ffe03ebe"},{"seconds":0.11671292199753225,"allocations":1188567,"digest":"c9f80c4d8291acd6aa580fc3b926618601e0b4447d4fe1fc429fcd12ffe03ebe"}]}
3
+ {"name":"expression_sort","rows":4000,"ruby":"3.4.1","samples":[{"seconds":0.5577583269914612,"allocations":3766689,"digest":"48b1db8b2bb1cc9f2034b6445b3bf7fc90d46b0422760951d156ad4e9407495b"},{"seconds":0.3787725990405306,"allocations":3766689,"digest":"48b1db8b2bb1cc9f2034b6445b3bf7fc90d46b0422760951d156ad4e9407495b"},{"seconds":0.3747718200320378,"allocations":3766689,"digest":"48b1db8b2bb1cc9f2034b6445b3bf7fc90d46b0422760951d156ad4e9407495b"}]}
data/benchmark/sort.rb ADDED
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run with: scripts/benchmark-sort 4000
4
+ require 'fat_table'
5
+ require 'digest'
6
+ require 'json'
7
+
8
+ row_count = Integer(ENV.fetch('BENCH_ROWS', '4000'))
9
+ raise ArgumentError, 'row count must be positive' unless row_count.positive?
10
+
11
+ data = Array.new(row_count) { |i|
12
+ {
13
+ id: i,
14
+ score: i % 64,
15
+ category: "Category #{i % 4}",
16
+ active: [nil, false, true][i % 3],
17
+ date: Date.new(2026, 1, 1) + i % 8,
18
+ }
19
+ }.shuffle(random: Random.new(42))
20
+ table = FatTable::Table.from_aoh(data)
21
+ operations = {
22
+ numeric_sort: -> { table.order_by(:score) },
23
+ mixed_sort: -> { table.order_by(:category, :active!, :date) },
24
+ expression_sort: -> { table.order_with('score % 16') },
25
+ }
26
+
27
+ text_output = ARGV.include?('--text')
28
+ if text_output
29
+ puts "FatTable sort benchmarks — Ruby #{RUBY_VERSION}"
30
+ puts "Rows: #{row_count} | 3 samples after warmup"
31
+ puts
32
+ printf "% -20s %12s %12s %12s %14s\n", 'Operation', 'Median (ms)', 'Min (ms)', 'Max (ms)', 'Allocations'
33
+ puts '-' * 74
34
+ end
35
+
36
+ operations.each do |name, operation|
37
+ operation.call # Warm up before measuring; input construction is excluded.
38
+ samples = Array.new(3) do
39
+ GC.start
40
+ before = GC.stat(:total_allocated_objects)
41
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
42
+ result = operation.call
43
+ elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
44
+ allocated = GC.stat(:total_allocated_objects) - before
45
+ output = [result.headers, result.rows, result.boundaries]
46
+ { seconds: elapsed, allocations: allocated, digest: Digest::SHA256.hexdigest(Marshal.dump(output)) }
47
+ end
48
+ if text_output
49
+ times = samples.map { |sample| sample[:seconds] * 1000 }.sort
50
+ allocations = samples.map { |sample| sample[:allocations] }.sort
51
+ printf "% -20s %12.3f %12.3f %12.3f %14d\n", name, times[1], times.first, times.last, allocations[1]
52
+ else
53
+ puts JSON.generate(name: name, rows: row_count, ruby: RUBY_VERSION, samples: samples)
54
+ end
55
+ end
56
+
57
+ puts "\nAllocations are median object counts. Input construction and hashing are excluded." if text_output
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run with: bundle exec ruby -Ilib benchmark/transform_and_render.rb
4
+ # Set BENCH_ROWS and BENCH_GROUP_SIZE to vary the synthetic workload.
5
+ require 'fat_table'
6
+ require 'digest'
7
+ require 'json'
8
+
9
+ row_count = Integer(ENV.fetch('BENCH_ROWS', '4000'))
10
+ group_size = Integer(ENV.fetch('BENCH_GROUP_SIZE', '1'))
11
+ raise ArgumentError, 'row and group sizes must be positive' unless row_count.positive? && group_size.positive?
12
+
13
+ data = Array.new(row_count) { |i| { id: i, amount: i * 3, label: "Item #{i}" } }
14
+ table = FatTable::Table.from_aoh(data)
15
+ table.explicit_boundaries = (group_size - 1...row_count).step(group_size).to_a
16
+ report = FatTable::Table.from_aoh(data)
17
+ operations = {
18
+ select_groups: -> { table.select(:id, group_no: '@group')[:group_no] },
19
+ where_groups: -> { table.where('@group.even?')[:id] },
20
+ text_report: -> { report.to_text },
21
+ }
22
+
23
+ text_output = ARGV.include?('--text')
24
+ if text_output
25
+ puts "FatTable benchmarks — Ruby #{RUBY_VERSION}"
26
+ puts "Rows: #{row_count} | Group size: #{group_size} | 3 samples after warmup"
27
+ puts
28
+ printf "% -20s %12s %12s %12s %14s\n", 'Operation', 'Median (ms)', 'Min (ms)', 'Max (ms)', 'Allocations'
29
+ puts '-' * 74
30
+ end
31
+
32
+ operations.each do |name, operation|
33
+ operation.call # Warm up before measuring; input construction is excluded.
34
+ samples = Array.new(3) do
35
+ GC.start
36
+ before = GC.stat(:total_allocated_objects)
37
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
38
+ result = operation.call
39
+ elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
40
+ allocated = GC.stat(:total_allocated_objects) - before
41
+ { seconds: elapsed, allocations: allocated, digest: Digest::SHA256.hexdigest(Marshal.dump(result)) }
42
+ end
43
+ if text_output
44
+ times = samples.map { |sample| sample[:seconds] * 1000 }.sort
45
+ allocations = samples.map { |sample| sample[:allocations] }.sort
46
+ printf "% -20s %12.3f %12.3f %12.3f %14d\n", name, times[1], times.first, times.last, allocations[1]
47
+ else
48
+ puts JSON.generate(name: name, rows: row_count, group_size: group_size, samples: samples)
49
+ end
50
+ end
51
+
52
+ puts "\nAllocations are median object counts. Input construction and hashing are excluded." if text_output