File: benchmark

package info (click to toggle)
ruby-oj-introspect 0.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 168 kB
  • sloc: ansic: 193; ruby: 63; makefile: 7; sh: 4
file content (32 lines) | stat: -rwxr-xr-x 647 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env ruby

require "bundler/setup"
require "oj/introspect"
require "json"
require "benchmark/ips"

TEST_JSON = File.read("./spec/fixtures/vulnerabilities.json")

INTROSPECT_PARSER = Oj::Parser.introspect
FILTERED_INTROSPECT_PARSER = Oj::Introspect.new(filter: "remediations")
USUAL_PARSER = Oj::Parser.usual

Benchmark.ips do |b|
  b.report("Introspect") do
    INTROSPECT_PARSER.parse(TEST_JSON)
  end

  b.report("Filtered introspect") do
    FILTERED_INTROSPECT_PARSER.parse(TEST_JSON)
  end

  b.report("Oj usual") do
    USUAL_PARSER.parse(TEST_JSON)
  end

  b.report("stdlib") do
    JSON.parse(TEST_JSON)
  end

  b.compare!
end