Skip to content
This repository
Newer
Older
100644 73 lines (68 sloc) 1.599 kb
b50dda31 »
2010-06-01 update benchmark scripts so they'll run under 1.9.2 preview3
1 $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
679dc462 »
2010-12-19 update some paths for 1.9
2 $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
b50dda31 »
2010-06-01 update benchmark scripts so they'll run under 1.9.2 preview3
3
9a106da9 »
2009-05-14 renamed stream benchmark to parse, and added an encode benchmark
4 require 'rubygems'
5 require 'benchmark'
41e6b7da »
2010-12-19 move to rake-compiler, Bundler
6 require 'yajl'
498abff5 »
2009-05-29 set READ_BUFSIZE back to 8kb by default
7 require 'stringio'
83319ad4 »
2009-11-21 don't require json gem or activesupport for benchmarks
8 begin
9 require 'json'
10 rescue LoadError
11 end
c6868c13 »
2011-02-17 re-add ActiveSupport to encoding benchmark, add Psych and YAML
12 begin
13 require 'psych'
14 rescue LoadError
15 end
16 begin
17 require 'active_support'
18 rescue LoadError
19 end
9a106da9 »
2009-05-14 renamed stream benchmark to parse, and added an encode benchmark
20
365bdb79 »
2009-06-19 removing large json benchmark files to trim down gem size, more to come
21 filename = ARGV[0] || 'benchmark/subjects/ohai.json'
7fcf5fb6 »
2011-02-21 adding headings to benchmarks, adding a benchmark for streaming psych
22 hash = File.open(filename, 'rb') { |f| Yajl::Parser.new.parse(f.read) }
9a106da9 »
2009-05-14 renamed stream benchmark to parse, and added an encode benchmark
23
2fc8065b »
2009-11-04 update benchmarks to bring the GC into the picture a little more
24 times = ARGV[1] ? ARGV[1].to_i : 1000
9a106da9 »
2009-05-14 renamed stream benchmark to parse, and added an encode benchmark
25 puts "Starting benchmark encoding #{filename} #{times} times\n\n"
2fc8065b »
2009-11-04 update benchmarks to bring the GC into the picture a little more
26 Benchmark.bmbm { |x|
14a99ac9 »
2009-06-07 Yajl::Encoder.encode will now return the resulting JSON string if no …
27 io_encoder = Yajl::Encoder.new
7fcf5fb6 »
2011-02-21 adding headings to benchmarks, adding a benchmark for streaming psych
28 string_encoder = Yajl::Encoder.new
29
30 x.report("Yajl::Encoder#encode (to an IO)") {
9a106da9 »
2009-05-14 renamed stream benchmark to parse, and added an encode benchmark
31 times.times {
14a99ac9 »
2009-06-07 Yajl::Encoder.encode will now return the resulting JSON string if no …
32 io_encoder.encode(hash, StringIO.new)
33 }
34 }
7fcf5fb6 »
2011-02-21 adding headings to benchmarks, adding a benchmark for streaming psych
35 x.report("Yajl::Encoder#encode (to a String)") {
14a99ac9 »
2009-06-07 Yajl::Encoder.encode will now return the resulting JSON string if no …
36 times.times {
37 output = string_encoder.encode(hash)
9a106da9 »
2009-05-14 renamed stream benchmark to parse, and added an encode benchmark
38 }
39 }
83319ad4 »
2009-11-21 don't require json gem or activesupport for benchmarks
40 if defined?(JSON)
7fcf5fb6 »
2011-02-21 adding headings to benchmarks, adding a benchmark for streaming psych
41 x.report("JSON.generate") {
83319ad4 »
2009-11-21 don't require json gem or activesupport for benchmarks
42 times.times {
43 JSON.generate(hash)
44 }
9a106da9 »
2009-05-14 renamed stream benchmark to parse, and added an encode benchmark
45 }
83319ad4 »
2009-11-21 don't require json gem or activesupport for benchmarks
46 end
c6868c13 »
2011-02-17 re-add ActiveSupport to encoding benchmark, add Psych and YAML
47 if defined?(Psych)
7fcf5fb6 »
2011-02-21 adding headings to benchmarks, adding a benchmark for streaming psych
48 x.report("Psych.to_json") {
c6868c13 »
2011-02-17 re-add ActiveSupport to encoding benchmark, add Psych and YAML
49 times.times {
50 Psych.to_json(hash)
51 }
52 }
4fbb8235 »
2011-02-21 looks like Psych::JSON::Stream isn't in 1.9.2
53 if defined?(Psych::JSON::Stream)
54 x.report("Psych::JSON::Stream") {
55 times.times {
56 io = StringIO.new
57 stream = Psych::JSON::Stream.new io
58 stream.start
59 stream.push hash
60 stream.finish
61 }
7fcf5fb6 »
2011-02-21 adding headings to benchmarks, adding a benchmark for streaming psych
62 }
4fbb8235 »
2011-02-21 looks like Psych::JSON::Stream isn't in 1.9.2
63 end
c6868c13 »
2011-02-17 re-add ActiveSupport to encoding benchmark, add Psych and YAML
64 end
65 if defined?(ActiveSupport::JSON)
7fcf5fb6 »
2011-02-21 adding headings to benchmarks, adding a benchmark for streaming psych
66 x.report("ActiveSupport::JSON.encode") {
c6868c13 »
2011-02-17 re-add ActiveSupport to encoding benchmark, add Psych and YAML
67 times.times {
68 ActiveSupport::JSON.encode(hash)
69 }
70 }
71 end
9a106da9 »
2009-05-14 renamed stream benchmark to parse, and added an encode benchmark
72 }
Something went wrong with that request. Please try again.