Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'ruby-prof'
- require 'fileutils'
- require 'listen'
- def write_results(result, type)
- FileUtils.mkdir("results") unless File.directory?("results")
- printer = RubyProf::FlatPrinter.new(result)
- printer.print(File.new("results/result-#{type}.txt", "w"))
- printer = RubyProf::GraphHtmlPrinter.new(result)
- printer.print(File.new("results/result-#{type}.html", "w"))
- printer = RubyProf::DotPrinter.new(result)
- printer.print(File.new("results/result-#{type}.dot", "w"))
- end
- def run_test(listener)
- t = Thread.new { listener.start }
- sleep(0.5)
- RubyProf.start
- FileUtils.touch 'test'
- FileUtils.rm 'test'
- Thread.kill(t)
- RubyProf.stop
- end
- #####################
- # Without FChange
- #####################
- puts "Profiling without fchange"
- result = run_test(Listen.to(Dir.pwd, :force_polling => true))
- write_results(result, "no-fchange")
- #####################
- # With FChange
- #####################
- puts "Profiling with fchange"
- result = run_test(Listen.to(Dir.pwd))
- write_results(result, "fchange")
- puts "Finished profiling"
Add Comment
Please, Sign In to add comment