Closed u2 closed 8 years ago
Hi! Pardon me, as I am helping @JuanitoFatas to clear the PRs.
I think we would prefer to merge comparison between atomic and generic actions.
The actions performed in this PR include access and delete
, and seems to be
more logic-dependent than generic in nature. So I would lean towards closing this PR.
:kissing_heart:
I would also like to point out that comparison is incorrect.
In slow
version you are creating a new (!) array at the end instead of returning original env
.
With this patch:
--- assignment_array_elements.rb 2016-02-10 21:21:27.403563391 +0100
+++ assignment_array_elements_fixed.rb 2016-02-10 21:22:02.691562471 +0100
@@ -3,7 +3,7 @@
def slow(env)
status, headers, body = env
headers.delete('Http-Access-Token')
- [status, headers, body]
+ env
end
def fast(env)
@@ -22,7 +22,7 @@
def slow_ext(env)
status, headers, body = env
headers['X-Clacks-Overhead'] = 'GNU Terry Pratchett'
- [status, headers, body]
+ env
end
def fast_ext(env)
Results will become:
Calculating -------------------------------------
element objects Assignment
115.648k i/100ms
array Assignment 126.859k i/100ms
-------------------------------------------------
element objects Assignment
4.492M (± 6.2%) i/s - 22.320M
array Assignment 4.840M (± 0.7%) i/s - 24.230M
Comparison:
array Assignment: 4840436.0 i/s
element objects Assignment: 4491909.9 i/s - 1.08x slower
Calculating -------------------------------------
element objects Assignment
127.003k i/100ms
array Assignment 131.268k i/100ms
-------------------------------------------------
element objects Assignment
4.529M (± 3.4%) i/s - 22.607M
array Assignment 5.262M (± 2.7%) i/s - 26.385M
Comparison:
array Assignment: 5262202.4 i/s
element objects Assignment: 4529275.0 i/s - 1.16x slower
Inspired by avoid run time allocations