README.md in pb_actor-0.0.1 vs README.md in pb_actor-0.0.2
- old
+ new
@@ -18,10 +18,11 @@
## Usage
```ruby
require 'pb_actor'
+require 'benchmark'
class Test
include PbActor
def fib(n)
if n < 2
@@ -34,25 +35,39 @@
def p_fib(n)
puts fib(n)
end
end
-f = Test.new
+t = Test.new
#=> <PbActor::Proxy:0x00000002106448 @origin=#<Test:0x00000002106470>, @pid=23487, @rd=#<IO:fd 7>, @wr=#<IO:fd 10>>
-f.alive?
+t.alive?
#=> true
-f.fib(30)
+t.fib(30)
#=> 1346269
-f.async.p_fib(30)
+t.async.p_fib(30)
#=> nil
# 1346269
-f.terminate
-f.alive?
+t.terminate
+t.alive?
#=> false
+
+def fib n
+ if n < 2
+ 1
+ else
+ fib(n - 1) + fib(n - 2)
+ end
+end
+
+Benchmark.bm do |bm|
+ bm.report{puts (30..35).map{|n| fib(n)}.reduce(:+)}
+ bm.report{puts (30..35).map{|n| Test.new.future.fib(n)}.map(&:value).reduce(:+)}
+end
+#=> Try it youself!
```
## Contributing
1. Fork it