

Ruby 2.1: Profiling Ruby - tmm1
http://tmm1.net/ruby21-profiling/

======
VeejayRampay
I wonder if this API allow will foster a big movement to track down all the
performance-hungry calls in say, Rails, and help the framework move forward in
terms of efficiency. This is really a welcome addition anyway.

------
akx
I think TRWTF here is that checking for (query string?) parameter existence
runs a regexp...

~~~
sams99
Some of us like to pre-divine a world devoid of bugs and silliness, others
like to provide us with tooling to track stuff down

------
wrl
So, I'm a Ruby neophyte. Why did adding parenthesis speed that line up so
much?

~~~
MaulingMonkey
Rewritten in longer form, assuming I've made no mistakes, the two versions are
equivalent to...

    
    
      if params[:user_id].present?
        if !@owner
          @owner = User.find_by_login(params[:user_id])
        end
      end
    

vs

    
    
      if !@owner
        if params[:user_id].present?
          @owner = User.find_by_login(params[:user_id])
        end
      end
    

Checking the member variable truthiness is presumably faster than a dictionary
lookup followed by a call to "present?". As @owner is probably
frequently/always true after the first call (it will be unless find_by_login
returns false/nil/? or another method resets @owner, given the same instance),
this leads to fewer dictionary lookups and present? calls, resulting in a
performance increase.

EDIT: Well that was an amusing spam of simultaneous answers.

------
gazarsgo
Why is line level profiling so non-existent for dynamic languages? Function
level just doesn't cut it, esp. w/ the zillions of monkey patches in Ruby.

~~~
sams99
Wait, what about stackprof rb-lineprof flamegraph rack-mini-profiler

------
kbar13
At first I didn't realize OP was a GitHub employee and thought he was munging
his company's GHE appliance :o

Cool read!

