pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Ruby pastebin - collaborative debugging tool View Help


Posted by Anonymous on Thu 20 Mar 14:40
report abuse | download | new post

  1. #!/usr/bin/env ruby
  2. # Script for checking whether pages are made dirty after a garbage collection.
  3.  
  4. def load_rails
  5.         require 'rubygems'
  6.         gem 'rails'
  7.         require 'initializer'
  8.         require 'active_support'
  9.         require 'action_controller'
  10.         require 'action_view'
  11.         require 'active_record'
  12.         puts "Loaded Ruby on Rails version #{Rails::VERSION::STRING}"
  13. end
  14.  
  15. def print_statistics
  16.         if ObjectSpace.respond_to?(:statistics)
  17.                 puts "========================================================="
  18.                 puts "--------------- Before garbage collection ---------------"
  19.                 puts ObjectSpace.statistics
  20.         end
  21.         ObjectSpace.garbage_collect
  22.         if ObjectSpace.respond_to?(:statistics)
  23.                 puts "--------------- After garbage collection ----------------"
  24.                 puts ObjectSpace.statistics
  25.                 puts "========================================================="
  26.         end
  27. end
  28.  
  29. def start
  30.         if GC.respond_to?(:copy_on_write_friendly=)
  31.                 GC.copy_on_write_friendly = true
  32.         end
  33.         load_rails
  34.         ObjectSpace.garbage_collect
  35.        
  36.         pid = fork do
  37.                 pid = fork do
  38.                         puts "Child process #{$$} created. Press Enter to start garbage collection."
  39.                         STDIN.readline
  40.                        
  41.                         print_statistics
  42.                         puts "Garbage collection finished. Press Enter to exit."
  43.                         STDIN.readline
  44.                         exit!
  45.                 end
  46.                 Process.waitpid(pid)
  47.                 exit!
  48.         end
  49.         Process.waitpid(pid)
  50. end
  51.  
  52. start

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post