Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Ruby profiling - David Grayson
Search
Las Vegas Ruby Group
August 28, 2013
94
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ruby profiling - David Grayson
Las Vegas Ruby Group
August 28, 2013
More Decks by Las Vegas Ruby Group
See All by Las Vegas Ruby Group
Ruby ISO Standard - David Grayson
lvrug
0
180
Windows Automation - Howard Feldman
lvrug
0
120
Separating Your Application from Rails - Brian Hughes
lvrug
0
170
SWIG and Ruby - David Grayson
lvrug
0
110
Practical Object-Oriented Design in Ruby - Charles Jackson
lvrug
3
160
The Hamster Gem - Ryan Mulligan
lvrug
1
140
Varnish+Redis - Russ Smith
lvrug
1
150
Lambdas and Pops - Jan Hettich
lvrug
0
130
Making Good Use of Fonts - Russ Smith
lvrug
1
120
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.2k
How to train your dragon (web standard)
notwaldorf
97
6.8k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.1k
For a Future-Friendly Web
brad_frost
183
10k
Product Roadmaps are Hard
iamctodd
55
13k
Marketing to machines
jonoalderson
1
5.8k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
580
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
340
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
Transcript
Ruby profiling David Grayson Las Vegas Ruby Meetup 2013-08-28
None
Two profiling tools ruby-prof rblineprof
Features of ruby-prof Speed Can measure: call
times memory usage object allocations Text and HTML reports: Flat profiles Graph profiles Call tree profiles for KCacheGrind Supports multiple threads
Example ruby-prof profiles
ruby-prof executable ruby-prof --file=profile.html \ --printer=graph_html \ slow_program.rb ruby-prof slow_program.rb
ruby-prof API require 'ruby-prof' RubyProf.start slow_code result = RubyProf.stop File.open("slow2.txt","w")
do |file| RubyProf::GraphPrinter.new(result).print(file) end
Excluding methods in ruby-prof Exclude methods by class/method name
or regular expression. Remove useless things like Integer#times from reports. New!
rblineprof 652-line ruby extension written in C Seems
to report the time spent on each line. No documentation, no report formatting
| class Foo | def x 2112.8ms 2112.3ms 3 |
y; z; z | end | | def y 2031.6ms 2031.2ms 51 | 50.times { z } | end | | def z 14.7ms 14.6ms 52 | waste_cpu 0 2096.0ms 2095.6ms 52 | waste_cpu 0.04 | end | | def waste_cpu(seconds) 5.1ms 5.1ms 312 | start = Time.now 1875.4ms 1876.4ms 109375 | while(Time.now - start < seconds); end | end | end | | require 'rblineprof' | profile = lineprof(/./) do 2112.9ms 2112.4ms 3 | Foo.new.x | end | | File.readlines(__FILE__).each_with_index do |line, num| | sample = profile[__FILE__][num+1] | if sample[0] > 0 | sample_data = sprintf "%8.1fms %8.1fms %7d", | sample[0]/1000.0, sample[1]/1000.0, sample[2], line | end | printf "%30s | %s", sample_data, line | end
References ruby-prof https://github.com/ruby-prof/ruby-prof/ rblineprof https://github.com/tmm1/rblineprof
https://github.com/blog/1475-escape-velocity