Created
March 1, 2016 15:17
-
-
Save mechanicles/aa2ef38a7b24a49b1e19 to your computer and use it in GitHub Desktop.
Profile without freeze
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'memory_profiler' | |
require 'active_support/core_ext/string' | |
def translate_without_freeze(key) | |
if key.to_s.first == '.' | |
"products/index".tr('/', '.') | |
end | |
end | |
report = MemoryProfiler.report(ignore_files: 'active_support/core_ext/string') do | |
30.times { translate_without_freeze('.name') } | |
end | |
report.pretty_print | |
# allocated memory by file | |
# ----------------------------------- | |
# 7200 benchmark_without_freeze.rb | |
# allocated objects by file | |
# ----------------------------------- | |
# 180 benchmark_without_freeze.rb | |
# Allocated String Report | |
# ----------------------------------- | |
# 60 "." | |
# 30 benchmark_without_freeze.rb:5 | |
# 30 benchmark_without_freeze.rb:6 | |
# | |
# 30 ".name" | |
# 30 benchmark_without_freeze.rb:11 | |
# | |
# 30 "/" | |
# 30 benchmark_without_freeze.rb:6 | |
# | |
# 30 "products.index" | |
# 30 benchmark_without_freeze.rb:6 | |
# | |
# 30 "products/index" | |
# 30 benchmark_without_freeze.rb:6 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment