Skip to content

Instantly share code, notes, and snippets.

@IFilonov
Last active March 24, 2023 05:18
Show Gist options
  • Select an option

  • Save IFilonov/8d27f8c5fb8efc5e46d3a01fe33e55e0 to your computer and use it in GitHub Desktop.

Select an option

Save IFilonov/8d27f8c5fb8efc5e46d3a01fe33e55e0 to your computer and use it in GitHub Desktop.
== profile by cpu
require 'stackprof'
profile = StackProf.run(mode: :wall, raw: true) do
process(period: period, search_query: ['toDate(created_at) BETWEEN ? AND ?', period&.begin, period&.end])
end
File.write('stackprof.json', JSON.generate(profile))
# Go to https://www.speedscope.app/
# and load json file
== profile by mem
require 'memory_profiler'
report = MemoryProfiler.report do
iaas_controller.send(action.to_sym, HashWithIndifferentAccess.new(params_from_headers))
GC.start
end
report.pretty_print(scales_bytes: true, to_file: "#{action}_#{rand(1000)}.txt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment