parallel 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.travis.yml +2 -0
- data/Gemfile.lock +1 -1
- data/Readme.md +28 -17
- data/lib/parallel.rb +1 -1
- data/lib/parallel/version.rb +1 -1
- data/spec/parallel_spec.rb +1 -0
- metadata +5 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -3,25 +3,35 @@ Best suited for map-reduce or e.g. parallel downloads/uploads.
|
|
3
3
|
|
4
4
|
Install
|
5
5
|
=======
|
6
|
-
|
6
|
+
|
7
|
+
```Bash
|
8
|
+
gem install parallel
|
9
|
+
```
|
7
10
|
|
8
11
|
Usage
|
9
12
|
=====
|
10
|
-
# 2 CPUs -> work in 2 processes (a,b + c)
|
11
|
-
results = Parallel.map(['a','b','c']) do |one_letter|
|
12
|
-
expensive_calculation(one_letter)
|
13
|
-
end
|
14
13
|
|
15
|
-
|
16
|
-
|
14
|
+
```Ruby
|
15
|
+
# 2 CPUs -> work in 2 processes (a,b + c)
|
16
|
+
results = Parallel.map(['a','b','c']) do |one_letter|
|
17
|
+
expensive_calculation(one_letter)
|
18
|
+
end
|
19
|
+
|
20
|
+
# 3 Processes -> finished after 1 run
|
21
|
+
results = Parallel.map(['a','b','c'], :in_processes=>3){|one_letter| ... }
|
17
22
|
|
18
|
-
|
19
|
-
|
23
|
+
# 3 Threads -> finished after 1 run
|
24
|
+
results = Parallel.map(['a','b','c'], :in_threads=>3){|one_letter| ... }
|
25
|
+
```
|
20
26
|
|
21
27
|
Same can be done with `each`
|
22
|
-
|
28
|
+
```Ruby
|
29
|
+
Parallel.each(['a','b','c']){|one_letter| ... }
|
30
|
+
```
|
23
31
|
or `each_with_index` or `map_with_index`
|
24
32
|
|
33
|
+
Processes/Threads are workers, they grab the next piece of work when they finish.
|
34
|
+
|
25
35
|
### Processes
|
26
36
|
- Speedup through multiple CPUs
|
27
37
|
- Speedup for blocking operations
|
@@ -59,15 +69,16 @@ Parallel.map(User.all) do |user|
|
|
59
69
|
end
|
60
70
|
```
|
61
71
|
|
62
|
-
Processes/Threads are workers, they grab the next piece of work when they finish
|
63
|
-
|
64
72
|
### Progress / ETA
|
65
73
|
|
74
|
+
```Bash
|
75
|
+
gem install ruby-progressbar
|
76
|
+
```
|
77
|
+
|
66
78
|
```Ruby
|
67
|
-
require 'progressbar'
|
68
|
-
progress = ProgressBar.
|
69
|
-
Parallel.map(1..100, :finish => lambda { |i, item| progress.
|
70
|
-
progress.finish
|
79
|
+
require 'ruby-progressbar'
|
80
|
+
progress = ProgressBar.create(:title => "The Progress", :total => 100)
|
81
|
+
Parallel.map(1..100, :finish => lambda { |i, item| progress.increment }) { sleep 1 }
|
71
82
|
```
|
72
83
|
|
73
84
|
Tips
|
@@ -103,4 +114,4 @@ Authors
|
|
103
114
|
[Michael Grosser](http://grosser.it)<br/>
|
104
115
|
michael@grosser.it<br/>
|
105
116
|
License: MIT<br/>
|
106
|
-
[![
|
117
|
+
[![Build Status](https://travis-ci.org/grosser/parallel.png)](https://travis-ci.org/grosser/parallel)
|
data/lib/parallel.rb
CHANGED
@@ -118,7 +118,7 @@ module Parallel
|
|
118
118
|
when /darwin/
|
119
119
|
(hwprefs_available? ? `hwprefs thread_count` : `sysctl -n hw.ncpu`).to_i
|
120
120
|
when /linux|cygwin/
|
121
|
-
`grep -c processor /proc/cpuinfo`.to_i
|
121
|
+
`grep -c ^processor /proc/cpuinfo`.to_i
|
122
122
|
when /(open|free)bsd/
|
123
123
|
`sysctl -n hw.ncpu`.to_i
|
124
124
|
when /mswin|mingw/
|
data/lib/parallel/version.rb
CHANGED
data/spec/parallel_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
VHNmKzZNYWVud0FNa0FnSGRzd0dzSnp0T25ObkJhM0YKeTBrQ1NXbUs2RCt4
|
37
37
|
L1NiZlM2cjdLZTA3TVJxemlKZEI5R3VFMSswY0lSdUZoOEVRK0xONkhYQ0tN
|
38
38
|
NXBvbi9HVQp5Y3dNWGZsMAotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
39
|
-
date: 2013-
|
39
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
40
40
|
dependencies: []
|
41
41
|
description:
|
42
42
|
email: michael@grosser.it
|
@@ -44,6 +44,7 @@ executables: []
|
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
|
+
- .travis.yml
|
47
48
|
- Gemfile
|
48
49
|
- Gemfile.lock
|
49
50
|
- MIT-LICENSE.txt
|
@@ -99,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
100
|
version: '0'
|
100
101
|
segments:
|
101
102
|
- 0
|
102
|
-
hash:
|
103
|
+
hash: 4198447693548042537
|
103
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
105
|
none: false
|
105
106
|
requirements:
|
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
109
|
version: '0'
|
109
110
|
segments:
|
110
111
|
- 0
|
111
|
-
hash:
|
112
|
+
hash: 4198447693548042537
|
112
113
|
requirements: []
|
113
114
|
rubyforge_project:
|
114
115
|
rubygems_version: 1.8.25
|
metadata.gz.sig
CHANGED
Binary file
|