如何加速 Ruby/Rake 任务 [英] How can I speed up Ruby/Rake task

查看:39
本文介绍了如何加速 Ruby/Rake 任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

rake --tasks 大约需要 18 秒才能运行.这只是加载所有任务所需的时间,因此我定义的任何任务至少需要这样的时间来运行:

rake --tasks takes about 18s to run. This is just the time it takes to load all the tasks, as a result any task I define will take at least this amount of time to run :

$time rake --tasks
rake db:clean           # Cleaning up database
rake passenger:restart  # Restart Application
rake spec               # Run specs

real    0m18.816s
user    0m7.306s
sys 0m5.665s

我的 Rakefile :

My Rakefile :

$: << "."
require "rubygems"
require "rspec/core/rake_task"

desc "Run those specs"
task :spec do
  RSpec::Core::RakeTask.new(:spec) do |t|
    t.rspec_opts = %w{--colour --format progress}
    t.pattern = 'spec/*_spec.rb'
  end
end

task :default  => :spec

知道为什么 rake 需要很多次吗?谢谢

Any idea why rake takes to much times ? Thanks

推荐答案

尝试 spring

命令行看起来像:

spring rake -T

第一次运行需要更多时间,但后续运行会非常快.

It will take more time running the first time, but subsequent runs will be very fast.

这篇关于如何加速 Ruby/Rake 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆