Skip to content

Commit 83f1331

Browse files
Use an Array of floats for the json float benchmark
JSON dictionary keys are always strings, so this benchmark could be seen to be misleading, as only the values are floats, the keys will be implicitly converted when the hash is converted to json. I've chosen to do use an array here instead of explicilty converting the keys into strings because it avoids the complexity of string interpolation, and it keeps the original intention of this micro benchmark which was to have all the contents of the data structure homogenous.
1 parent b5591c3 commit 83f1331

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

benchmarks-ractor/json_parse_float/benchmark.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,10 @@
77

88
ELEMENTS = 100_000
99
list = ELEMENTS.times.map do
10-
{
11-
rand => rand,
12-
rand => rand,
13-
rand => rand,
14-
rand => rand,
15-
rand => rand,
16-
rand => rand,
17-
rand => rand,
18-
rand => rand,
19-
rand => rand,
20-
rand => rand,
21-
}.to_json
10+
[
11+
rand, rand, rand, rand, rand, rand, rand, rand, rand, rand,
12+
rand, rand, rand, rand, rand, rand, rand, rand, rand, rand,
13+
].to_json
2214
end
2315
Ractor.make_shareable(list)
2416

0 commit comments

Comments
 (0)