parallel_runner 0.0.1 → 0.0.2
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.
- data/.gitignore +32 -0
- data/.project +11 -0
- data/ChangeLog +7 -4
- data/README.md +32 -0
- data/Rakefile +143 -143
- data/gem/parallel_runner-0.0.1.gem +0 -0
- data/lib/parallel_runner.rb +40 -25
- data/parallel_runner.gemspec +13 -0
- data/spec/parallel_runner_helper.rb +74 -0
- data/spec/parallel_runner_spec.rb +36 -0
- metadata +37 -57
- data/README.rdoc +0 -46
data/.gitignore
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#*
|
2
|
+
*$
|
3
|
+
*.BAK
|
4
|
+
*.Z
|
5
|
+
*.bak
|
6
|
+
*.class
|
7
|
+
*.elc
|
8
|
+
*.ln
|
9
|
+
*.log
|
10
|
+
*.o
|
11
|
+
*.obj
|
12
|
+
*.olb
|
13
|
+
*.old
|
14
|
+
*.orig
|
15
|
+
*.pyc
|
16
|
+
*.pyo
|
17
|
+
*.rej
|
18
|
+
*~
|
19
|
+
,*
|
20
|
+
.#*
|
21
|
+
.DS_Store
|
22
|
+
.del-*
|
23
|
+
.deployables
|
24
|
+
.make.state
|
25
|
+
.nse_depinfo
|
26
|
+
.svn
|
27
|
+
CVS.adm
|
28
|
+
RCS
|
29
|
+
RCSLOG
|
30
|
+
SCCS
|
31
|
+
_$*
|
32
|
+
_svn
|
data/.project
ADDED
data/ChangeLog
CHANGED
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#parallel_runner
|
2
|
+
"parallel_runner" is simple parallel processing support library.
|
3
|
+
|
4
|
+
###Installation
|
5
|
+
gem install parallel_runner
|
6
|
+
|
7
|
+
###Usage
|
8
|
+
For list:
|
9
|
+
|
10
|
+
require 'parallel_runner'
|
11
|
+
['a', 'b', 'c'].each_with_parallel do |value|
|
12
|
+
# your processing
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'parallel_runner'
|
16
|
+
['a', 'b', 'c'].each_with_parallel do |value, index|
|
17
|
+
# your processing
|
18
|
+
end
|
19
|
+
|
20
|
+
For map:
|
21
|
+
|
22
|
+
require 'parallel_runner'
|
23
|
+
{:name => 'alice', age => 17}.each_with_parallel do |key, value|
|
24
|
+
# your processing
|
25
|
+
end
|
26
|
+
|
27
|
+
##Author
|
28
|
+
Ryuichi TANAKA <mapserver2007@gmail.com>
|
29
|
+
|
30
|
+
##License
|
31
|
+
Licensed under the MIT
|
32
|
+
http://www.opensource.org/licenses/mit-license.php
|
data/Rakefile
CHANGED
@@ -1,143 +1,143 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'rake/clean'
|
4
|
-
require 'rake/testtask'
|
5
|
-
require 'rake/packagetask'
|
6
|
-
require 'rake/gempackagetask'
|
7
|
-
require 'rake/rdoctask'
|
8
|
-
require 'rake/contrib/rubyforgepublisher'
|
9
|
-
require 'rake/contrib/sshpublisher'
|
10
|
-
require 'fileutils'
|
11
|
-
include FileUtils
|
12
|
-
|
13
|
-
NAME = "parallel_runner"
|
14
|
-
AUTHOR = "mapserver2007"
|
15
|
-
EMAIL = "mapserver2007@gmail.com"
|
16
|
-
DESCRIPTION = "simple parallel processing library."
|
17
|
-
RUBYFORGE_PROJECT = "parallel_runner"
|
18
|
-
HOMEPATH = "http://github.com/#{AUTHOR}/#{NAME}"
|
19
|
-
BIN_FILES = %w( )
|
20
|
-
VERS = '0.0.1'
|
21
|
-
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
22
|
-
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
23
|
-
RDOC_OPTS = [
|
24
|
-
'--title', "#{NAME} documentation",
|
25
|
-
"--charset", "utf-8",
|
26
|
-
"--opname", "index.html",
|
27
|
-
"--line-numbers",
|
28
|
-
"--main", "README.rdoc",
|
29
|
-
"--inline-source",
|
30
|
-
]
|
31
|
-
|
32
|
-
task :default => [:test]
|
33
|
-
task :package => [:clean]
|
34
|
-
|
35
|
-
Rake::TestTask.new("test") do |t|
|
36
|
-
t.libs << "test"
|
37
|
-
t.pattern = "test/**/*_test.rb"
|
38
|
-
t.verbose = true
|
39
|
-
end
|
40
|
-
|
41
|
-
spec = Gem::Specification.new do |s|
|
42
|
-
s.name = NAME
|
43
|
-
s.version = VERS
|
44
|
-
s.platform = Gem::Platform::RUBY
|
45
|
-
s.has_rdoc = true
|
46
|
-
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
|
47
|
-
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
|
48
|
-
s.summary = DESCRIPTION
|
49
|
-
s.description = DESCRIPTION
|
50
|
-
s.author = AUTHOR
|
51
|
-
s.email = EMAIL
|
52
|
-
s.homepage = HOMEPATH
|
53
|
-
s.executables = BIN_FILES
|
54
|
-
s.rubyforge_project = RUBYFORGE_PROJECT
|
55
|
-
s.bindir = "bin"
|
56
|
-
s.require_path = "lib"
|
57
|
-
#s.autorequire = ""
|
58
|
-
s.test_files = Dir["spec/*.rb"]
|
59
|
-
#s.test_files = Dir["test/*_test.rb"]
|
60
|
-
|
61
|
-
#s.add_dependency('activesupport', '>=1.3.1')
|
62
|
-
#s.required_ruby_version = '>= 1.8.2'
|
63
|
-
|
64
|
-
s.files = %w(README.rdoc ChangeLog Rakefile) +
|
65
|
-
Dir.glob("{bin,doc,test,lib,templates,generator,extras,website,script}/**/*") +
|
66
|
-
Dir.glob("ext/**/*.{h,c,rb}") +
|
67
|
-
Dir.glob("examples/**/*.rb") +
|
68
|
-
Dir.glob("tools/*.rb") +
|
69
|
-
Dir.glob("rails/*.rb")
|
70
|
-
|
71
|
-
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
72
|
-
end
|
73
|
-
|
74
|
-
Rake::GemPackageTask.new(spec) do |p|
|
75
|
-
p.need_tar = true
|
76
|
-
p.gem_spec = spec
|
77
|
-
end
|
78
|
-
|
79
|
-
task :install do
|
80
|
-
name = "#{NAME}-#{VERS}.gem"
|
81
|
-
sh %{rake package}
|
82
|
-
sh %{sudo gem install pkg/#{name}}
|
83
|
-
end
|
84
|
-
|
85
|
-
task :uninstall => [:clean] do
|
86
|
-
sh %{sudo gem uninstall #{NAME}}
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
Rake::RDocTask.new do |rdoc|
|
91
|
-
rdoc.rdoc_dir = 'html'
|
92
|
-
rdoc.options += RDOC_OPTS
|
93
|
-
rdoc.template = "resh"
|
94
|
-
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
95
|
-
if ENV['DOC_FILES']
|
96
|
-
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
|
97
|
-
else
|
98
|
-
rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
|
99
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
100
|
-
rdoc.rdoc_files.include('ext/**/*.c')
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
desc "Publish to RubyForge"
|
105
|
-
task :rubyforge => [:rdoc, :package] do
|
106
|
-
require 'rubyforge'
|
107
|
-
Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, 'stay').upload
|
108
|
-
end
|
109
|
-
|
110
|
-
desc 'Package and upload the release to rubyforge.'
|
111
|
-
task :release => [:clean, :package] do |t|
|
112
|
-
v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
|
113
|
-
abort "Versions don't match #{v} vs #{VERS}" unless v == VERS
|
114
|
-
pkg = "pkg/#{NAME}-#{VERS}"
|
115
|
-
|
116
|
-
require 'rubyforge'
|
117
|
-
rf = RubyForge.new.configure
|
118
|
-
puts "Logging in"
|
119
|
-
rf.login
|
120
|
-
|
121
|
-
c = rf.userconfig
|
122
|
-
# c["release_notes"] = description if description
|
123
|
-
# c["release_changes"] = changes if changes
|
124
|
-
c["preformatted"] = true
|
125
|
-
|
126
|
-
files = [
|
127
|
-
"#{pkg}.tgz",
|
128
|
-
"#{pkg}.gem"
|
129
|
-
].compact
|
130
|
-
|
131
|
-
puts "Releasing #{NAME} v. #{VERS}"
|
132
|
-
rf.add_release RUBYFORGE_PROJECT, NAME, VERS, *files
|
133
|
-
end
|
134
|
-
|
135
|
-
desc 'Show information about the gem.'
|
136
|
-
task :debug_gem do
|
137
|
-
puts spec.to_ruby
|
138
|
-
end
|
139
|
-
|
140
|
-
desc 'Update gem spec'
|
141
|
-
task :gemspec do
|
142
|
-
open("#{NAME}.gemspec", 'w').write spec.to_ruby
|
143
|
-
end
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'rake/contrib/rubyforgepublisher'
|
9
|
+
require 'rake/contrib/sshpublisher'
|
10
|
+
require 'fileutils'
|
11
|
+
include FileUtils
|
12
|
+
|
13
|
+
NAME = "parallel_runner"
|
14
|
+
AUTHOR = "mapserver2007"
|
15
|
+
EMAIL = "mapserver2007@gmail.com"
|
16
|
+
DESCRIPTION = "simple parallel processing library."
|
17
|
+
RUBYFORGE_PROJECT = "parallel_runner"
|
18
|
+
HOMEPATH = "http://github.com/#{AUTHOR}/#{NAME}"
|
19
|
+
BIN_FILES = %w( )
|
20
|
+
VERS = '0.0.1'
|
21
|
+
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
22
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
23
|
+
RDOC_OPTS = [
|
24
|
+
'--title', "#{NAME} documentation",
|
25
|
+
"--charset", "utf-8",
|
26
|
+
"--opname", "index.html",
|
27
|
+
"--line-numbers",
|
28
|
+
"--main", "README.rdoc",
|
29
|
+
"--inline-source",
|
30
|
+
]
|
31
|
+
|
32
|
+
task :default => [:test]
|
33
|
+
task :package => [:clean]
|
34
|
+
|
35
|
+
Rake::TestTask.new("test") do |t|
|
36
|
+
t.libs << "test"
|
37
|
+
t.pattern = "test/**/*_test.rb"
|
38
|
+
t.verbose = true
|
39
|
+
end
|
40
|
+
|
41
|
+
spec = Gem::Specification.new do |s|
|
42
|
+
s.name = NAME
|
43
|
+
s.version = VERS
|
44
|
+
s.platform = Gem::Platform::RUBY
|
45
|
+
s.has_rdoc = true
|
46
|
+
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
|
47
|
+
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
|
48
|
+
s.summary = DESCRIPTION
|
49
|
+
s.description = DESCRIPTION
|
50
|
+
s.author = AUTHOR
|
51
|
+
s.email = EMAIL
|
52
|
+
s.homepage = HOMEPATH
|
53
|
+
s.executables = BIN_FILES
|
54
|
+
s.rubyforge_project = RUBYFORGE_PROJECT
|
55
|
+
s.bindir = "bin"
|
56
|
+
s.require_path = "lib"
|
57
|
+
#s.autorequire = ""
|
58
|
+
s.test_files = Dir["spec/*.rb"]
|
59
|
+
#s.test_files = Dir["test/*_test.rb"]
|
60
|
+
|
61
|
+
#s.add_dependency('activesupport', '>=1.3.1')
|
62
|
+
#s.required_ruby_version = '>= 1.8.2'
|
63
|
+
|
64
|
+
s.files = %w(README.rdoc ChangeLog Rakefile) +
|
65
|
+
Dir.glob("{bin,doc,test,lib,templates,generator,extras,website,script}/**/*") +
|
66
|
+
Dir.glob("ext/**/*.{h,c,rb}") +
|
67
|
+
Dir.glob("examples/**/*.rb") +
|
68
|
+
Dir.glob("tools/*.rb") +
|
69
|
+
Dir.glob("rails/*.rb")
|
70
|
+
|
71
|
+
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
72
|
+
end
|
73
|
+
|
74
|
+
Rake::GemPackageTask.new(spec) do |p|
|
75
|
+
p.need_tar = true
|
76
|
+
p.gem_spec = spec
|
77
|
+
end
|
78
|
+
|
79
|
+
task :install do
|
80
|
+
name = "#{NAME}-#{VERS}.gem"
|
81
|
+
sh %{rake package}
|
82
|
+
sh %{sudo gem install pkg/#{name}}
|
83
|
+
end
|
84
|
+
|
85
|
+
task :uninstall => [:clean] do
|
86
|
+
sh %{sudo gem uninstall #{NAME}}
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
Rake::RDocTask.new do |rdoc|
|
91
|
+
rdoc.rdoc_dir = 'html'
|
92
|
+
rdoc.options += RDOC_OPTS
|
93
|
+
rdoc.template = "resh"
|
94
|
+
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
95
|
+
if ENV['DOC_FILES']
|
96
|
+
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
|
97
|
+
else
|
98
|
+
rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
|
99
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
100
|
+
rdoc.rdoc_files.include('ext/**/*.c')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
desc "Publish to RubyForge"
|
105
|
+
task :rubyforge => [:rdoc, :package] do
|
106
|
+
require 'rubyforge'
|
107
|
+
Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, 'stay').upload
|
108
|
+
end
|
109
|
+
|
110
|
+
desc 'Package and upload the release to rubyforge.'
|
111
|
+
task :release => [:clean, :package] do |t|
|
112
|
+
v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
|
113
|
+
abort "Versions don't match #{v} vs #{VERS}" unless v == VERS
|
114
|
+
pkg = "pkg/#{NAME}-#{VERS}"
|
115
|
+
|
116
|
+
require 'rubyforge'
|
117
|
+
rf = RubyForge.new.configure
|
118
|
+
puts "Logging in"
|
119
|
+
rf.login
|
120
|
+
|
121
|
+
c = rf.userconfig
|
122
|
+
# c["release_notes"] = description if description
|
123
|
+
# c["release_changes"] = changes if changes
|
124
|
+
c["preformatted"] = true
|
125
|
+
|
126
|
+
files = [
|
127
|
+
"#{pkg}.tgz",
|
128
|
+
"#{pkg}.gem"
|
129
|
+
].compact
|
130
|
+
|
131
|
+
puts "Releasing #{NAME} v. #{VERS}"
|
132
|
+
rf.add_release RUBYFORGE_PROJECT, NAME, VERS, *files
|
133
|
+
end
|
134
|
+
|
135
|
+
desc 'Show information about the gem.'
|
136
|
+
task :debug_gem do
|
137
|
+
puts spec.to_ruby
|
138
|
+
end
|
139
|
+
|
140
|
+
desc 'Update gem spec'
|
141
|
+
task :gemspec do
|
142
|
+
open("#{NAME}.gemspec", 'w').write spec.to_ruby
|
143
|
+
end
|
Binary file
|
data/lib/parallel_runner.rb
CHANGED
@@ -1,26 +1,41 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'thread'
|
3
|
+
|
4
|
+
module ParallelRunner
|
5
|
+
def self.each(object, concurency = 10, qsize = nil, &block)
|
6
|
+
q = qsize ? SizedQueue.new(qsize) : Queue.new
|
7
|
+
threads = []
|
8
|
+
producer = Thread.start(q, concurency) do |pq, pc|
|
9
|
+
if object.instance_of? Array
|
10
|
+
object.each_with_index {|value, index| pq.enq([[value, index], true])}
|
11
|
+
elsif object.instance_of? Hash
|
12
|
+
object.each {|key, value| pq.enq([[key, value], true])}
|
13
|
+
end
|
14
|
+
pc.times{pq.enq([nil, false])}
|
15
|
+
end
|
16
|
+
workers = []
|
17
|
+
concurency.times do
|
18
|
+
workers << Thread.start(q) do |wq|
|
19
|
+
elem, flg = wq.deq
|
20
|
+
while flg
|
21
|
+
block.call(elem[0], elem[1])
|
22
|
+
elem, flg = wq.deq
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
producer.join
|
27
|
+
workers.each{|w| w.join}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Hash
|
32
|
+
def each_with_parallel(concurency = 10, qsize = nil, &block)
|
33
|
+
ParallelRunner.each(self, concurency, qsize, &block)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Array
|
38
|
+
def each_with_parallel(concurency = 10, qsize = nil, &block)
|
39
|
+
ParallelRunner.each(self, concurency, qsize, &block)
|
40
|
+
end
|
26
41
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |gem|
|
3
|
+
gem.authors = ["mapserver2007"]
|
4
|
+
gem.email = ["mapserver2007@gmail.com"]
|
5
|
+
gem.description = %q{Simple parallel processing library.}
|
6
|
+
gem.summary = %q{Simple parallel processing library.}
|
7
|
+
gem.homepage = "https://github.com/mapserver2007/parallel_runner"
|
8
|
+
gem.files = `git ls-files`.split($\)
|
9
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
10
|
+
gem.name = "parallel_runner"
|
11
|
+
gem.require_paths = ["lib"]
|
12
|
+
gem.version = '0.0.2'
|
13
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'rspec'
|
3
|
+
require 'mechanize'
|
4
|
+
require File.dirname(__FILE__) + "/../lib/parallel_runner"
|
5
|
+
|
6
|
+
def exec_time
|
7
|
+
t = Time.now.to_f
|
8
|
+
yield
|
9
|
+
Time.now.to_f - t
|
10
|
+
end
|
11
|
+
|
12
|
+
def list
|
13
|
+
[
|
14
|
+
"http://www.yahoo.co.jp",
|
15
|
+
"http://www.google.co.jp",
|
16
|
+
"http://twitter.com/",
|
17
|
+
"http://www.hatena.ne.jp/"
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
def map
|
22
|
+
{
|
23
|
+
:yahoo => "http://www.yahoo.co.jp",
|
24
|
+
:google => "http://www.google.co.jp",
|
25
|
+
:twitter => "http://twitter.com/",
|
26
|
+
:hatena => "http://www.hatena.ne.jp/"
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def time_by_each_with_parallel
|
31
|
+
agent = Mechanize.new
|
32
|
+
exec_time {
|
33
|
+
list.each_with_parallel do |url|
|
34
|
+
site = agent.get(url)
|
35
|
+
html = site.root.xpath("//title")[0].inner_html
|
36
|
+
html.should_not be_nil
|
37
|
+
end
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def time_by_each
|
42
|
+
agent = Mechanize.new
|
43
|
+
exec_time {
|
44
|
+
list.each do |url|
|
45
|
+
site = agent.get(url)
|
46
|
+
html = site.root.xpath("//title")[0].inner_html
|
47
|
+
html.should_not be_nil
|
48
|
+
end
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def time_by_each_with_index
|
53
|
+
agent = Mechanize.new
|
54
|
+
exec_time {
|
55
|
+
list.each_with_index do |url, index|
|
56
|
+
site = agent.get(url)
|
57
|
+
html = site.root.xpath("//title")[0].inner_html
|
58
|
+
html.should_not be_nil
|
59
|
+
end
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
def time_by_each_by_map
|
64
|
+
agent = Mechanize.new
|
65
|
+
exec_time {
|
66
|
+
map.each do |name, url|
|
67
|
+
site = agent.get(url)
|
68
|
+
html = site.root.xpath("//title")[0].inner_html
|
69
|
+
html.should_not be_nil
|
70
|
+
end
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'parallel_runner_helper'
|
3
|
+
|
4
|
+
describe 'parallel_runner' do
|
5
|
+
it "Iterate list in parallel" do
|
6
|
+
list.each_with_parallel do |val|
|
7
|
+
val.should_not be_empty
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "Iterate list with index in parallel" do
|
12
|
+
list.each_with_parallel do |val, index|
|
13
|
+
val.should_not be_empty
|
14
|
+
index.to_s.should match(/^\d$/)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "Iterate map in parallel" do
|
19
|
+
map.each_with_parallel do |key, value|
|
20
|
+
key.should_not be_empty
|
21
|
+
value.should_not be_empty
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "faster than Array#each" do
|
26
|
+
time_by_each.should be > time_by_each_with_parallel
|
27
|
+
end
|
28
|
+
|
29
|
+
it "faster than Array#each_with_index" do
|
30
|
+
time_by_each_with_index.should be > time_by_each_with_parallel
|
31
|
+
end
|
32
|
+
|
33
|
+
it "faster than Hash#each" do
|
34
|
+
time_by_each_by_map.should be > time_by_each_with_parallel
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,79 +1,59 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel_runner
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 0.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- mapserver2007
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
date: 2010-12-24 00:00:00 +09:00
|
12
|
+
date: 2012-06-16 00:00:00.000000000 +09:00
|
18
13
|
default_executable:
|
19
14
|
dependencies: []
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
description: Simple parallel processing library.
|
16
|
+
email:
|
17
|
+
- mapserver2007@gmail.com
|
23
18
|
executables: []
|
24
|
-
|
25
19
|
extensions: []
|
26
|
-
|
27
|
-
|
28
|
-
-
|
29
|
-
-
|
30
|
-
files:
|
31
|
-
- README.rdoc
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- .project
|
32
24
|
- ChangeLog
|
25
|
+
- README.md
|
33
26
|
- Rakefile
|
27
|
+
- gem/parallel_runner-0.0.1.gem
|
34
28
|
- lib/parallel_runner.rb
|
29
|
+
- parallel_runner.gemspec
|
30
|
+
- spec/parallel_runner_helper.rb
|
31
|
+
- spec/parallel_runner_spec.rb
|
35
32
|
has_rdoc: true
|
36
|
-
homepage:
|
33
|
+
homepage: https://github.com/mapserver2007/parallel_runner
|
37
34
|
licenses: []
|
38
|
-
|
39
35
|
post_install_message:
|
40
|
-
rdoc_options:
|
41
|
-
|
42
|
-
- parallel_runner documentation
|
43
|
-
- --charset
|
44
|
-
- utf-8
|
45
|
-
- --opname
|
46
|
-
- index.html
|
47
|
-
- --line-numbers
|
48
|
-
- --main
|
49
|
-
- README.rdoc
|
50
|
-
- --inline-source
|
51
|
-
- --exclude
|
52
|
-
- ^(examples|extras)/
|
53
|
-
require_paths:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
54
38
|
- lib
|
55
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
40
|
none: false
|
57
|
-
requirements:
|
58
|
-
- -
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
|
62
|
-
version: "0"
|
63
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
46
|
none: false
|
65
|
-
requirements:
|
66
|
-
- -
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
|
69
|
-
- 0
|
70
|
-
version: "0"
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
71
51
|
requirements: []
|
72
|
-
|
73
|
-
|
74
|
-
rubygems_version: 1.3.7
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 1.6.2
|
75
54
|
signing_key:
|
76
55
|
specification_version: 3
|
77
|
-
summary:
|
78
|
-
test_files:
|
79
|
-
|
56
|
+
summary: Simple parallel processing library.
|
57
|
+
test_files:
|
58
|
+
- spec/parallel_runner_helper.rb
|
59
|
+
- spec/parallel_runner_spec.rb
|
data/README.rdoc
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
= parallel-runner
|
2
|
-
|
3
|
-
"parallel-runner" is simple parallel processing support library.
|
4
|
-
|
5
|
-
== Installation
|
6
|
-
|
7
|
-
execute a command.
|
8
|
-
|
9
|
-
gem install parallel_runner
|
10
|
-
|
11
|
-
=== Usage
|
12
|
-
require 'parallel_runner'
|
13
|
-
Runner.parallel(list) do |elem|
|
14
|
-
# write processing
|
15
|
-
end
|
16
|
-
|
17
|
-
Please refer to sample/runner.rb
|
18
|
-
|
19
|
-
== Copyright
|
20
|
-
|
21
|
-
* Author:: mapserver2007(Ryuichi TANAKA) <mapserver2007@gmail.com>
|
22
|
-
* Copyright:: Copyright (c) 2010 mapserver2007
|
23
|
-
|
24
|
-
== License
|
25
|
-
|
26
|
-
(The MIT License)
|
27
|
-
|
28
|
-
Copyright (c) 2010 Ryuichi Tanaka
|
29
|
-
|
30
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
31
|
-
of this software and associated documentation files (the "Software"), to deal
|
32
|
-
in the Software without restriction, including without limitation the rights
|
33
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
34
|
-
copies of the Software, and to permit persons to whom the Software is
|
35
|
-
furnished to do so, subject to the following conditions:
|
36
|
-
|
37
|
-
The above copyright notice and this permission notice shall be included in
|
38
|
-
all copies or substantial portions of the Software.
|
39
|
-
|
40
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
41
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
42
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
43
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
44
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
45
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
46
|
-
THE SOFTWARE.
|