running scripts with bundle exec is slow [closed]

2019-07-30 02:42发布

When running with bundle exec

$ time bundle exec rails generate model student name:string age:number
      invoke  active_record
      create    db/migrate/20121215170617_create_students.rb
      create    app/models/student.rb

real    0m13.397s
user    0m11.676s
sys     0m0.597s

Running directly

$ time rails generate model student name:string age:number
      invoke  active_record
      create    db/migrate/20121215171018_create_students.rb
      create    app/models/student.rb

real    0m6.408s
user    0m5.783s
sys     0m0.510s

$ ruby -v
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux]

so, normal the command takes 6seconds but with bundle exec, its slow & takes twice the the time.

so, is just me or bundle exec is just slow?

1条回答
三岁会撩人
2楼-- · 2019-07-30 03:39

Using bundle exec with rails command is redundant.

So don't run bundle exec before rails command, this command is already aware of Bundler and sets up everything according to what you have on your Gemfile. If you prepend bundle exec before rails command all you will be adding is overhead of opening another process from Bundler and executing useless code since rails already does the right thing.

Gotten from here.

查看更多
登录 后发表回答