Skip to content

Commit 22d585c

Browse files
committed
Nicer debug; compare caching by serializer, grouped by caching on/off
bundle exec bin/bench_regression a5eaf6cd7a7fed42d9e64777753a1762e187eadc 1033b71 --pattern bm_caching ["perf/only_calc_associations_once", "a5eaf6cd7a7fed42d9e64777753a1762e187eadc", "1033b711c7d7c231bb5b832e7dfe7f99389f22c4", "a5eaf6c"] "version": "0.10.0.rc5", "rails_version": "4.2.6", "benchmark_run[environment]": "2.2.2p95", Note: checking out 'a5eaf6cd7a7fed42d9e64777753a1762e187eadc'. HEAD is now at a5eaf6c... Nicer debug; compare caching by serializer, grouped by caching on/off caching on: caching serializers: gc off 783.6956866669746/ips; 1355 objects caching on: non-caching serializers: gc off 798.8629770532652/ips; 1257 objects caching off: caching serializers: gc off 682.3661326140281/ips; 1355 objects caching off: non-caching serializers: gc off 721.2175067555897/ips; 1257 objects HEAD is now at 1033b71... Merge pull request #1638 from bf4/caching_redux caching on: caching serializers: gc off 570.6905948477781/ips; 1803 objects caching on: non-caching serializers: gc off 822.8418206976623/ips; 1257 objects caching off: caching serializers: gc off 523.4174806572001/ips; 1803 objects caching off: non-caching serializers: gc off 747.6026493097758/ips; 1257 objects
1 parent b7e2bc0 commit 22d585c

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

test/benchmark/bm_caching.rb

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ def get_non_caching(on_off = 'on'.freeze)
3535
get("/non_caching/#{on_off}")
3636
end
3737

38+
def debug(msg = '')
39+
if block_given? && ENV['DEBUG'] =~ /\Atrue|on|0\z/i
40+
STDERR.puts yield
41+
else
42+
STDERR.puts msg
43+
end
44+
end
45+
3846
private
3947

4048
def assert_responses(caching, non_caching)
@@ -86,32 +94,21 @@ def assert_equal(expected, actual, message)
8694
end
8795
end
8896

89-
def debug(msg = '')
90-
if block_given? && ENV['DEBUG'] =~ /\Atrue|on|0\z/i
91-
STDERR.puts yield
92-
else
93-
STDERR.puts msg
94-
end
95-
end
9697
end
9798
assertion = ApiAssertion.new
9899
assertion.valid?
99-
# STDERR.puts assertion.get_status
100+
assertion.debug { assertion.get_status }
100101

101102
time = 10
102103
{
103104
'caching on: caching serializers: gc off' => { disable_gc: true, send: [:get_caching, 'on'] },
104-
# 'caching on: caching serializers: gc on' => { disable_gc: false, send: [:get_caching, 'on'] },
105-
'caching off: caching serializers: gc off' => { disable_gc: true, send: [:get_caching, 'off'] },
106-
# 'caching off: caching serializers: gc on' => { disable_gc: false, send: [:get_caching, 'off'] },
107105
'caching on: non-caching serializers: gc off' => { disable_gc: true, send: [:get_non_caching, 'on'] },
108-
# 'caching on: non-caching serializers: gc on' => { disable_gc: false, send: [:get_non_caching, 'on'] },
106+
'caching off: caching serializers: gc off' => { disable_gc: true, send: [:get_caching, 'off'] },
109107
'caching off: non-caching serializers: gc off' => { disable_gc: true, send: [:get_non_caching, 'off'] }
110-
# 'caching off: non-caching serializers: gc on' => { disable_gc: false, send: [:get_non_caching, 'off'] }
111108
}.each do |label, options|
112109
assertion.clear
113110
Benchmark.ams(label, time: time, disable_gc: options[:disable_gc]) do
114111
assertion.send(*options[:send])
115112
end
116-
# STDERR.puts assertion.get_status(options[:send][-1])
113+
assertion.debug { assertion.get_status(options[:send][-1]) }
117114
end

0 commit comments

Comments
 (0)