Skip to content

Instantly share code, notes, and snippets.

@NZKoz
Created January 28, 2014 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NZKoz/8675428 to your computer and use it in GitHub Desktop.
Save NZKoz/8675428 to your computer and use it in GitHub Desktop.
Koz-Prostyle-2:store michaelkoziarski$ time /usr/bin/ruby -e ''
real 0m0.117s
user 0m0.031s
sys 0m0.056s
Koz-Prostyle-2:store michaelkoziarski$ time ~/.rbenv/shims/ruby -e ''
real 0m0.096s
user 0m0.057s
sys 0m0.038s
@stevenharman
Copy link

What does time ruby -e '' look like? For me, it's slower than /usr/bin/ruby but faster than ~/.rbenv/shims/ruby. WUT?

@stevenharman
Copy link

(2.0.0p247) $ time /usr/bin/ruby -e ''
/usr/bin/ruby -e ''  0.03s user 0.02s system 82% cpu 0.052 total

(2.0.0p353) $ time ~/.rbenv/shims/ruby -e ''
~/.rbenv/shims/ruby -e ''  0.06s user 0.03s system 90% cpu 0.096 total

(2.0.0p353) $ time ruby -e ''
ruby -e ''  0.05s user 0.03s system 89% cpu 0.096 total

@NZKoz
Copy link
Author

NZKoz commented Jan 28, 2014

time ruby -e '' is statistically indistinguishable from the ~/.rbenv one

@garybernhardt
Copy link

Those are probably different versions of ruby; check ruby -v with each.

@pusewicz
Copy link

~ 2.1.0 $ time /usr/bin/ruby -e ''
        0.14 real         0.05 user         0.07 sys
~ 2.1.0 $ time /usr/bin/ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
        0.01 real         0.00 user         0.00 sys
~ 2.1.0 $ time ruby -e ''
        0.25 real         0.10 user         0.13 sys
~ 2.1.0 $ time ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
        0.13 real         0.04 user         0.07 sys

@sdball
Copy link

sdball commented Jan 28, 2014

$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-darwin13.0.2]
$ time ruby -e ''
ruby -e ''  0.01s user 0.00s system 94% cpu 0.011 total

$ chruby 2.0
$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.2]
$ time ruby -e ''
ruby -e ''  0.02s user 0.00s system 93% cpu 0.027 total

$ chruby 2.1
$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
$ time ruby -e ''
ruby -e ''  0.02s user 0.01s system 96% cpu 0.031 total

¯\_(ツ)_/¯

@postmodern
Copy link

With chruby and ruby 2.0.0-p353:

$ /usr/bin/ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
$ time /usr/bin/ruby -e ''
real    0m0.350s
user    0m0.115s
sys 0m0.043s
$ chruby ruby-2.0.0-p353
$ which ruby
~/.rubies/ruby-2.0.0-p353/bin/ruby
$ time ruby -e ''
real    0m0.031s
user    0m0.029s
sys 0m0.002s

If you do not want any additional overhead when invoking ruby, I highly recommend trying chruby.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment