Permalink
Browse files

adding an artificial slowdown to the word count example, for demonstr…

…ation purposes
  • Loading branch information...
jashkenas committed Dec 5, 2009
1 parent 898b028 commit 0d385425c0e424c6bd1f797493422fd2a4074fa2
Showing with 6 additions and 4 deletions.
  1. +6 −4 actions/word_count.rb
View
@@ -1,14 +1,16 @@
-# A parallel WordCount. Depends on the 'wc' utility.
+# A parallel WordCount. Depends on the 'wc' utility.
class WordCount < CloudCrowd::Action
-
+
# Count the words in a single book.
+ # Pretend that this takes longer than it really does, for demonstration purposes.
def process
+ sleep 5
(`wc -w #{input_path}`).match(/\A\s*(\d+)/)[1].to_i
end
-
+
# Sum the total word count.
def merge
input.inject(0) {|sum, count| sum + count }
end
-
+
end

0 comments on commit 0d38542

Please sign in to comment.