forkjoin 1.0.0-java → 1.0.1-java

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.
Files changed (3) hide show
  1. data/examples/wordcount.rb +25 -14
  2. data/forkjoin.gemspec +1 -1
  3. metadata +1 -1
@@ -1,17 +1,28 @@
1
1
  require 'forkjoin'
2
+ require 'benchmark'
2
3
 
3
- pool = ForkJoin::Pool.new
4
+ file = ARGV.shift
4
5
 
5
- map_futures = pool.invoke_all(
6
- ARGF.each_line.map{|line| ->{line.split.map{|word| [word,1]}}}
7
- )
8
- counts = map_futures.map(&:get).inject({}) {|map, value|
9
- value.each {|k,v| (map[k] ||= []) << v}
10
- map
11
- }
12
- reduced_futures = pool.invoke_all(
13
- counts.map{|k, vs| ->{[k, vs.size]}}
14
- )
15
- reduced_futures.map(&:get).each{|value|
16
- puts "%s %d\n" % value
17
- }
6
+ 5.times do
7
+ Benchmark.bm do |bm|
8
+ bm.report do
9
+ pool = ForkJoin::Pool.new
10
+ map_futures = nil
11
+ File.open(file) do |f|
12
+ map_futures = pool.invoke_all(
13
+ f.each_line.map { |line| -> { line.split.map { |word| [word,1] } } }
14
+ )
15
+ end
16
+ counts = map_futures.map(&:get).inject({}) { |map, value|
17
+ value.each { |k, v| (map[k] ||= []) << v }
18
+ map
19
+ }
20
+ reduced_futures = pool.invoke_all(
21
+ counts.map { |k, vs| -> { [k, vs.size] } }
22
+ )
23
+ # reduced_futures.map(&:get).each{|value|
24
+ # puts "%s %d\n" % value
25
+ # }
26
+ end
27
+ end
28
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{forkjoin}
5
- s.version = "1.0.0"
5
+ s.version = "1.0.1"
6
6
  s.authors = ["Charles Oliver Nutter", "Nakamura Hiroshi"]
7
7
  s.date = Time.now.strftime('%Y-%m-%d')
8
8
  s.description = "A JRuby extension to efficiently wrap the JSR166 Fork/Join framework."
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: forkjoin
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.0.1
6
6
  platform: java
7
7
  authors:
8
8
  - Charles Oliver Nutter