Skip to content

Commit 2f08296

Browse files
committed
Merge pull request #50 from charliesome/fix-parallel-assignment-benchmark
Return nil from assignment benchmarks
2 parents eb87b69 + 463a82f commit 2f08296

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,22 @@ Idioms
4646

4747
##### Parallel Assignment vs Sequential Assignment [code](code/general/assignment.rb)
4848

49-
> Parallel Assignment allocates an extra array.
50-
5149
```
5250
$ ruby -v code/general/assignment.rb
53-
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
51+
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin13]
5452
5553
Calculating -------------------------------------
56-
Parallel Assignment 99.146k i/100ms
57-
Sequential Assignment 127.143k i/100ms
54+
Parallel Assignment 103.520k i/100ms
55+
Sequential Assignment
56+
105.474k i/100ms
5857
-------------------------------------------------
59-
Parallel Assignment 2.522M (± 7.5%) i/s - 12.592M
60-
Sequential Assignment 5.686M (± 8.6%) i/s - 28.226M
58+
Parallel Assignment 7.049M (± 2.7%) i/s - 35.300M
59+
Sequential Assignment
60+
6.159M (± 2.3%) i/s - 30.798M
6161
6262
Comparison:
63-
Sequential Assignment: 5685750.0 i/s
64-
Parallel Assignment: 2521708.9 i/s - 2.25x slower
63+
Parallel Assignment: 7048523.9 i/s
64+
Sequential Assignment: 6159203.7 i/s - 1.14x slower
6565
```
6666

6767
##### `begin...rescue` vs `respond_to?` for Control Flow [code](code/general/begin-rescue-vs-respond-to.rb)

code/general/assignment.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
def slow
44
a, b, c, d, e, f, g, h = 1, 2, 3, 4, 5, 6, 7, 8
5+
nil
56
end
67

78
def fast
@@ -13,6 +14,7 @@ def fast
1314
f = 6
1415
g = 7
1516
h = 8
17+
nil
1618
end
1719

1820
Benchmark.ips do |x|

0 commit comments

Comments
 (0)