From e440268d51fe02b303e3817a7a733a0dac1c5091 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Tue, 5 Nov 2024 09:16:08 +0100 Subject: [PATCH] Get rid of JSON benchmarks --- benchmark/parser.rb | 39 --------------------------------------- benchmark/standalone.rb | 41 ----------------------------------------- 2 files changed, 80 deletions(-) delete mode 100644 benchmark/parser.rb delete mode 100644 benchmark/standalone.rb diff --git a/benchmark/parser.rb b/benchmark/parser.rb deleted file mode 100644 index 1c26ed8d407789..00000000000000 --- a/benchmark/parser.rb +++ /dev/null @@ -1,39 +0,0 @@ -require "benchmark/ips" -require "json" -require "oj" -require "rapidjson" - -if ENV["ONLY"] - RUN = ENV["ONLY"].split(/[,: ]/).map{|x| [x.to_sym, true] }.to_h - RUN.default = false -elsif ENV["EXCEPT"] - RUN = ENV["EXCEPT"].split(/[,: ]/).map{|x| [x.to_sym, false] }.to_h - RUN.default = true -else - RUN = Hash.new(true) -end - -def benchmark_parsing(name, json_output) - puts "== Parsing #{name} (#{json_output.size} bytes)" - - Benchmark.ips do |x| - x.report("json") { JSON.parse(json_output) } if RUN[:json] - x.report("oj") { Oj.load(json_output) } if RUN[:oj] - x.report("oj strict") { Oj.strict_load(json_output) } if RUN[:oj] - x.report("Oj::Parser") { Oj::Parser.usual.parse(json_output) } if RUN[:oj] - x.report("rapidjson") { RapidJSON.parse(json_output) } if RUN[:rapidjson] - x.compare!(order: :baseline) - end - puts -end - -benchmark_parsing "small nested array", JSON.dump([[1,2,3,4,5]]*10) -benchmark_parsing "small hash", JSON.dump({ "username" => "jhawthorn", "id" => 123, "event" => "wrote json serializer" }) - -benchmark_parsing "test from oj", <