mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Nicer debug; compare caching by serializer, grouped by caching on/off
bundle exec bin/bench_regression a5eaf6cd7a7fed42d9e64777753a1762e187eadc 1033b711c7d7c231bb5b832e7dfe7f99389f22c4 --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
This commit is contained in:
parent
b7e2bc06ed
commit
e554ba23d2
@ -35,6 +35,14 @@ class ApiAssertion
|
||||
get("/non_caching/#{on_off}")
|
||||
end
|
||||
|
||||
def debug(msg = '')
|
||||
if block_given? && ENV['DEBUG'] =~ /\Atrue|on|0\z/i
|
||||
STDERR.puts yield
|
||||
else
|
||||
STDERR.puts msg
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_responses(caching, non_caching)
|
||||
@ -85,33 +93,21 @@ class ApiAssertion
|
||||
STDERR.puts message unless ENV['SUMMARIZE']
|
||||
end
|
||||
end
|
||||
|
||||
def debug(msg = '')
|
||||
if block_given? && ENV['DEBUG'] =~ /\Atrue|on|0\z/i
|
||||
STDERR.puts yield
|
||||
else
|
||||
STDERR.puts msg
|
||||
end
|
||||
end
|
||||
end
|
||||
assertion = ApiAssertion.new
|
||||
assertion.valid?
|
||||
# STDERR.puts assertion.get_status
|
||||
assertion.debug { assertion.get_status }
|
||||
|
||||
time = 10
|
||||
{
|
||||
'caching on: caching serializers: gc off' => { disable_gc: true, send: [:get_caching, 'on'] },
|
||||
# 'caching on: caching serializers: gc on' => { disable_gc: false, send: [:get_caching, 'on'] },
|
||||
'caching off: caching serializers: gc off' => { disable_gc: true, send: [:get_caching, 'off'] },
|
||||
# 'caching off: caching serializers: gc on' => { disable_gc: false, send: [:get_caching, 'off'] },
|
||||
'caching on: non-caching serializers: gc off' => { disable_gc: true, send: [:get_non_caching, 'on'] },
|
||||
# 'caching on: non-caching serializers: gc on' => { disable_gc: false, send: [:get_non_caching, 'on'] },
|
||||
'caching off: caching serializers: gc off' => { disable_gc: true, send: [:get_caching, 'off'] },
|
||||
'caching off: non-caching serializers: gc off' => { disable_gc: true, send: [:get_non_caching, 'off'] }
|
||||
# 'caching off: non-caching serializers: gc on' => { disable_gc: false, send: [:get_non_caching, 'off'] }
|
||||
}.each do |label, options|
|
||||
assertion.clear
|
||||
Benchmark.ams(label, time: time, disable_gc: options[:disable_gc]) do
|
||||
assertion.send(*options[:send])
|
||||
end
|
||||
# STDERR.puts assertion.get_status(options[:send][-1])
|
||||
assertion.debug { assertion.get_status(options[:send][-1]) }
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user