Created
June 1, 2012 13:11
-
-
Save stereobooster/2852056 to your computer and use it in GitHub Desktop.
profile rb-fchange
This file contains 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
source :rubygems | |
gem 'ruby-prof', :git => "https://github.com/wycats/ruby-prof.git" | |
# gem 'perftools.rb', :git => 'git://github.com/tmm1/perftools.rb.git' | |
gem 'rb-fchange' | |
gem 'listen' |
This file contains 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
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" |
This file contains 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
require 'fileutils' | |
require 'listen' | |
require 'perftools' | |
##################### | |
# Without FChange | |
##################### | |
puts "Profiling without fchange" | |
listener = Listen.to(Dir.pwd, :force_polling => true) | |
t = Thread.new { listener.start } | |
sleep(0.5) | |
PerfTools::CpuProfiler.start("result/no-fchange") | |
FileUtils.touch 'test' | |
FileUtils.rm 'test' | |
PerfTools::CpuProfiler.stop | |
Thread.kill(t) | |
##################### | |
# With FChange | |
##################### | |
puts "Profiling with fchange" | |
listener = Listen.to(Dir.pwd) | |
t = Thread.new { listener.start } | |
sleep(0.5) | |
PerfTools::CpuProfiler.start("result/fchange") | |
FileUtils.touch 'test' | |
FileUtils.rm 'test' | |
PerfTools::CpuProfiler.stop | |
Thread.kill(t) | |
puts "Finished profiling" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment