duffy 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/duffy/system.rb +19 -5
- data/lib/duffy/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e08825eab80f162c76e7815a7be79bfc481a81f
|
4
|
+
data.tar.gz: e7ca62ca598dfa32a4ba3d4dbda468bdbe54e54d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47b1d4e7cdee31059a26845436300537a9227b380d91776eda64ca28457b240980990d588a1179c1af1952c746facc9cbb8ded54c3e202e4a2b4b0b7fef8d95e
|
7
|
+
data.tar.gz: ed3c3003ba38f10fb3ffd8b4baee7b35ee55d44fac0ed4708a4e2351d58785b3d791a602b900ca3b9118dfd7aa8df18fe1b802719d82b69565379e0745445aa0
|
data/README.md
CHANGED
@@ -46,7 +46,7 @@ This one is namespaced in case you use the 'git' gem. I found it to be overkill
|
|
46
46
|
```
|
47
47
|
|
48
48
|
CPU Detection:
|
49
|
-
Linux only for now, each method returns 1 on
|
49
|
+
Linux and Mac only for now, each method returns 1 on unsupported hosts.
|
50
50
|
Example results for my dual core i5 with hyperthreading.
|
51
51
|
```ruby
|
52
52
|
Duffy::System.cpus # => 1
|
data/lib/duffy/system.rb
CHANGED
@@ -9,20 +9,34 @@ module Duffy
|
|
9
9
|
class << self
|
10
10
|
|
11
11
|
# How many Physical CPUs do you have.
|
12
|
-
# Detected by counting unique physical IDs
|
12
|
+
# Linux: Detected by counting unique physical IDs
|
13
|
+
# Mac: hw.packages
|
13
14
|
def cpus
|
14
|
-
|
15
|
+
case RUBY_PLATFORM
|
16
|
+
when /linux/ then File.read('/proc/cpuinfo').scan(/^physical id.*/).uniq.count rescue 1
|
17
|
+
when /darwin/ then `sysctl -n hw.packages`.to_i rescue 1
|
18
|
+
else 1
|
19
|
+
end
|
15
20
|
end
|
16
21
|
|
17
22
|
# How many actual CPU cores do we have not including Hyperthreading
|
18
|
-
# "cpu cores" in cpuinfo is on a per physical processor basis, so we multiply by the number of CPUs
|
23
|
+
# Linux: "cpu cores" in cpuinfo is on a per physical processor basis, so we multiply by the number of CPUs
|
24
|
+
# Mac: hw.physicalcpu
|
19
25
|
def cores
|
20
|
-
|
26
|
+
case RUBY_PLATFORM
|
27
|
+
when /linux/ then (File.read('/proc/cpuinfo').scan(/^cpu cores.*/).first.scan(/\d+$/).first.to_i rescue 1) * cpus
|
28
|
+
when /darwin/ then `sysctl -n hw.physicalcpu`.to_i rescue 1
|
29
|
+
else 1
|
30
|
+
end
|
21
31
|
end
|
22
32
|
|
23
33
|
# How many threads does the system have.
|
24
34
|
def threads
|
25
|
-
|
35
|
+
case RUBY_PLATFORM
|
36
|
+
when /linux/ then File.read('/proc/cpuinfo').scan(/^processor\s*:/).size rescue 1
|
37
|
+
when /darwin/ then `sysctl -n hw.ncpu`.to_i rescue 1
|
38
|
+
else 1
|
39
|
+
end
|
26
40
|
end
|
27
41
|
|
28
42
|
end
|
data/lib/duffy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duffy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Duffy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
132
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.4.
|
133
|
+
rubygems_version: 2.4.6
|
134
134
|
signing_key:
|
135
135
|
specification_version: 4
|
136
136
|
summary: Library of things
|