Skip to content

Instantly share code, notes, and snippets.

@s7nfo
Created April 27, 2025 19:54
Show Gist options
  • Save s7nfo/6b8c8df58d72775d246ccce4b4f5ad90 to your computer and use it in GitHub Desktop.
Save s7nfo/6b8c8df58d72775d246ccce4b4f5ad90 to your computer and use it in GitHub Desktop.
profiler = ENV['PROFILER'] || 'none'
case profiler
when 'ruby-prof'
require 'ruby-prof'
RubyProf.start
when 'trace'
require 'trace'
Trace.init_buffer
end
def fibonacci(n)
return 1 if n <= 1
fibonacci(n - 1) + fibonacci(n - 2)
end
start_time = Time.now
fibonacci(30)
duration = Time.now - start_time
puts "duration: %.6f seconds" % duration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment