Module: FastRake

Extended by:
Rake::DSL
Defined in:
lib/fast_rake.rb,
lib/fast_rake/version.rb

Defined Under Namespace

Classes: FastRunner

Constant Summary collapse

VERSION_MAJOR =
0
VERSION_MINOR =
2
VERSION_PATCH =
8
VERSION =
[VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH].join('.')

Class Method Summary collapse

Class Method Details

._hwprefs_available?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/fast_rake.rb', line 49

def self._hwprefs_available?
  `which hwprefs` != ''
end

._processor_countObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fast_rake.rb', line 26

def self._processor_count
  case RbConfig::CONFIG['host_os']
  when /darwin9/
    `hwprefs cpu_count`.to_i
  when /darwin/
    (_hwprefs_available? ? `hwprefs thread_count` : `sysctl -n hw.ncpu`).to_i
  when /linux|cygwin/
    `grep -c processor /proc/cpuinfo`.to_i
  when /(open|free)bsd/
    `sysctl -n hw.ncpu`.to_i
  when /mswin|mingw/
    require 'win32ole'
    wmi = WIN32OLE.connect("winmgmts://")
    cpu = wmi.ExecQuery("select NumberOfLogicalProcessors from Win32_Processor")
    cpu.to_enum.first.NumberOfLogicalProcessors
  when /solaris2/
    `psrinfo -p`.to_i # this is physical cpus afaik
  else
    $stderr.puts "Unknown architecture ( #{RbConfig::CONFIG["host_os"]} ) assuming one processor."
    1
  end
end

.fast_runner_task(name, setup_tasks, run_tasks, fail_fast = true, processes = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fast_rake.rb', line 7

def self.fast_runner_task(name, setup_tasks, run_tasks, fail_fast=true, processes=nil)
  desc "Fast test runner for #{name.to_s}"
  task name, [:count, :list] => setup_tasks do |t, args|
    tasks_to_run = if !args[:list].nil?
      args[:list].split(' ')
    else
      run_tasks
    end
    if !args[:count].nil? and args[:count].to_i != 0
      processes = args[:count].to_i
    elsif processes.nil?
      processes = _processor_count 
      puts "#{processes} processors detected" 
    end
    FastRunner.new(tasks_to_run, processes, fail_fast).run
  end
end