aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/console_profile.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/console_profile.rb')
-rw-r--r--railties/lib/console_profile.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/railties/lib/console_profile.rb b/railties/lib/console_profile.rb
new file mode 100644
index 0000000000..afec28795d
--- /dev/null
+++ b/railties/lib/console_profile.rb
@@ -0,0 +1,14 @@
+# No GC nonsense.
+GC.disable
+
+# Try to load the ruby-prof extension; fail back to the pure-Ruby
+# profiler included in the standard library.
+begin
+ require 'prof'
+ Prof.clock_mode = Prof::CPU
+ puts 'Using the fast ruby-prof extension'
+ require 'unprof'
+rescue LoadError
+ puts 'Using the slow pure-Ruby profiler'
+ require 'profile'
+end