parallel 0.5.12 → 0.5.13

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.12
1
+ 0.5.13
@@ -78,13 +78,29 @@ class Parallel
78
78
  cpu = wmi.ExecQuery("select NumberOfLogicalProcessors from Win32_Processor")
79
79
  cpu.to_enum.first.NumberOfLogicalProcessors
80
80
  when /solaris2/
81
- `psrinfo -p`.to_i
81
+ `psrinfo -p`.to_i # this is physical cpus afaik
82
82
  else
83
83
  $stderr.puts "Unknown architecture ( #{RbConfig::CONFIG["host_os"]} ) assuming one processor."
84
84
  1
85
85
  end
86
86
  end
87
87
 
88
+ def self.physical_processor_count
89
+ case RbConfig::CONFIG['host_os']
90
+ when /darwin1/, /freebsd/
91
+ `sysctl -n hw.physicalcpu`.to_i
92
+ when /linux/
93
+ `grep cores /proc/cpuinfo`[/\d+/].to_i
94
+ when /mswin|mingw/
95
+ require 'win32ole'
96
+ wmi = WIN32OLE.connect("winmgmts://")
97
+ cpu = wmi.ExecQuery("select NumberOfProcessors from Win32_Processor")
98
+ cpu.to_enum.first.NumberOfLogicalProcessors
99
+ else
100
+ processor_count
101
+ end
102
+ end
103
+
88
104
  private
89
105
 
90
106
  def self.work_direct(array, options)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "parallel"
8
- s.version = "0.5.12"
8
+ s.version = "0.5.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = "2012-01-20"
12
+ s.date = "2012-02-01"
13
13
  s.email = "grosser.michael@gmail.com"
14
14
  s.files = [
15
15
  "Gemfile",
@@ -24,6 +24,16 @@ describe Parallel do
24
24
  end
25
25
  end
26
26
 
27
+ describe :physical_processor_count do
28
+ it "returns a number" do
29
+ (1..999).should include(Parallel.physical_processor_count)
30
+ end
31
+
32
+ it "is half or same as normal cpu" do
33
+ [Parallel.processor_count, Parallel.processor_count / 2].should include Parallel.physical_processor_count
34
+ end
35
+ end
36
+
27
37
  describe :in_processes do
28
38
  def cpus
29
39
  Parallel.processor_count
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 12
10
- version: 0.5.12
9
+ - 13
10
+ version: 0.5.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-20 00:00:00 Z
18
+ date: 2012-02-01 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: