blob: c67882396a39d68ec11bf8c938c84aa6fca726a1 (
plain)
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
|
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'benchmark-ips', '~> 2.8'
gem 'oj'
end
require 'benchmark/ips'
require 'json'
require 'oj'
Oj.default_options = { mode: :strict }
json = JSON.pretty_generate({
string: 'spandx',
number: 1234,
array: ['MIT']
})
Benchmark.ips do |x|
x.report('JSON.parse') { JSON.parse(json) }
x.report('OJ.load') { Oj.load(json) }
x.compare!
end
|