-
-
Save s7nfo/6b8c8df58d72775d246ccce4b4f5ad90 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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