running scripts with bundle exec is slow [closed]

跟風遠走 提交于 2019-12-24 11:35:29

问题


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:


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.



来源:https://stackoverflow.com/questions/13894966/running-scripts-with-bundle-exec-is-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!