Giter Site home page Giter Site logo

Comments (4)

hsbt avatar hsbt commented on July 30, 2024

Can you try it with $RBENV_ROOT/versions/3.2.3/bin/ruby? rbenv uses shell shims for invoking ruby or other related commands.

$ hyperfine "ruby -e 1"
Benchmark 1: ruby -e 1
  Time (mean ± σ):     166.6 ms ± 143.7 ms    [User: 37.1 ms, System: 20.4 ms]
  Range (min … max):   113.8 ms … 575.1 ms    10 runs

$ hyperfine "~/.local/share/rbenv/versions/3.2.3/bin/ruby -e 1"
Benchmark 1: ~/.local/share/rbenv/versions/3.2.3/bin/ruby -e 1
  Time (mean ± σ):      50.7 ms ±  38.0 ms    [User: 26.6 ms, System: 13.2 ms]
  Range (min … max):    39.6 ms … 187.9 ms    15 runs

from ruby-build.

appomsk avatar appomsk commented on July 30, 2024

Well. So it's shims... Just want Ruby to be a bit faster. I apologize for the anxiety. You can close the issue.

hyperfine '.rbenv/versions/3.2.4/bin/ruby -e 1'
Benchmark 1: .rbenv/versions/3.2.4/bin/ruby -e 1
  Time (mean ± σ):     110.1 ms ±   2.8 ms    [User: 84.5 ms, System: 25.1 ms]
  Range (min … max):   107.3 ms … 118.5 ms    26 runs
 
hyperfine '/usr/bin/ruby -e 1'
Benchmark 1: /usr/bin/ruby -e 1
  Time (mean ± σ):     106.7 ms ±   1.0 ms    [User: 82.3 ms, System: 24.1 ms]
  Range (min … max):   104.1 ms … 108.7 ms    27 runs

from ruby-build.

mislav avatar mislav commented on July 30, 2024

The slowness of rbenv as opposed to invoking a ruby binary directly is known and documented (linked from the README): https://github.com/rbenv/rbenv/wiki/Comparison-of-version-managers

from ruby-build.

mislav avatar mislav commented on July 30, 2024

Just want Ruby to be a bit faster

100 ms for a process startup can indeed feel slow, but sometimes that can't be helped with the Ruby interpreter. Depending on your system resources, 50–100 ms might be a reasonable amount of startup time. On my machine, it's more like 30 ms.

If you want to further speed up Ruby, you can disable it loading Rubygems with --disable-gems. Here it is on my Apple M1 machine:

$ hyperfine --warmup 5 '~/.rbenv/versions/3.2.2/bin/ruby --disable-gems -e 1'

  Time (mean ± σ):       6.2 ms ±   0.4 ms    [User: 3.6 ms, System: 2.1 ms]
  Range (min … max):     5.8 ms …   7.6 ms    360 runs

Of course, a ruby interpreted started this way is less useful because it won't be able to load any gem dependenices.

from ruby-build.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.