* [ruby-core:68558] [Ruby trunk - Misc #10983] [Open] Why blocks make Ruby methods 439% slower ?
[not found] <redmine.issue-10983.20150319090344@ruby-lang.org>
@ 2015-03-19 9:03 ` Sergey.V.Ezhov
2015-03-19 10:12 ` [ruby-core:68559] [Ruby trunk - Misc #10983] " ko1
2015-11-10 6:21 ` [ruby-core:71428] " nobu
2 siblings, 0 replies; 3+ messages in thread
From: Sergey.V.Ezhov @ 2015-03-19 9:03 UTC (permalink / raw
To: ruby-core
Issue #10983 has been reported by Сергей Е.
----------------------------------------
Misc #10983: Why blocks make Ruby methods 439% slower ?
https://bugs.ruby-lang.org/issues/10983
* Author: Сергей Е
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
https://www.omniref.com/ruby/2.2.0/symbols/Proc/yield#annotation=4087638&line=711&hn=1
require 'benchmark/ips'
def block_call(&block)
block.call
end
def just_yield
yield
end
Benchmark.ips do |x|
x.report("call") do
block_call { 1 + 1 }
end
x.report("just yield") do
just_yield { 1 + 1 }
end
x.compare!
end
I run on Ruby 2.2.1
Calculating -------------------------------------
call 40.754k i/100ms
just yield 69.031k i/100ms
-------------------------------------------------
call 814.929k (± 4.0%) i/s - 4.075M
just yield 2.871M (±25.1%) i/s - 12.909M
Comparison:
just yield: 2871127.3 i/s
call: 814929.3 i/s - 3.52x slower
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:68559] [Ruby trunk - Misc #10983] Why blocks make Ruby methods 439% slower ?
[not found] <redmine.issue-10983.20150319090344@ruby-lang.org>
2015-03-19 9:03 ` [ruby-core:68558] [Ruby trunk - Misc #10983] [Open] Why blocks make Ruby methods 439% slower ? Sergey.V.Ezhov
@ 2015-03-19 10:12 ` ko1
2015-11-10 6:21 ` [ruby-core:71428] " nobu
2 siblings, 0 replies; 3+ messages in thread
From: ko1 @ 2015-03-19 10:12 UTC (permalink / raw
To: ruby-core
Issue #10983 has been updated by Koichi Sasada.
To capture local variables and so on (== an environment) for several frames is too heavy.
For example,
```ruby
1.times{
1.times{
1.times{
Proc.new{}
}
}
}
```
you need to capture all blocks' environments.
You don't need to capture environments only passing block.
So you need to say "passing block is faster" :)
BTW, I agree it is slow.
Improve the performance on this behavior will be great job.
----------------------------------------
Misc #10983: Why blocks make Ruby methods 439% slower ?
https://bugs.ruby-lang.org/issues/10983#change-51875
* Author: Сергей Е
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
https://www.omniref.com/ruby/2.2.0/symbols/Proc/yield#annotation=4087638&line=711&hn=1
require 'benchmark/ips'
def block_call(&block)
block.call
end
def just_yield
yield
end
Benchmark.ips do |x|
x.report("call") do
block_call { 1 + 1 }
end
x.report("just yield") do
just_yield { 1 + 1 }
end
x.compare!
end
I run on Ruby 2.2.1
Calculating -------------------------------------
call 40.754k i/100ms
just yield 69.031k i/100ms
-------------------------------------------------
call 814.929k (± 4.0%) i/s - 4.075M
just yield 2.871M (±25.1%) i/s - 12.909M
Comparison:
just yield: 2871127.3 i/s
call: 814929.3 i/s - 3.52x slower
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:71428] [Ruby trunk - Misc #10983] Why blocks make Ruby methods 439% slower ?
[not found] <redmine.issue-10983.20150319090344@ruby-lang.org>
2015-03-19 9:03 ` [ruby-core:68558] [Ruby trunk - Misc #10983] [Open] Why blocks make Ruby methods 439% slower ? Sergey.V.Ezhov
2015-03-19 10:12 ` [ruby-core:68559] [Ruby trunk - Misc #10983] " ko1
@ 2015-11-10 6:21 ` nobu
2 siblings, 0 replies; 3+ messages in thread
From: nobu @ 2015-11-10 6:21 UTC (permalink / raw
To: ruby-core
Issue #10983 has been updated by Nobuyoshi Nakada.
Description updated
----------------------------------------
Misc #10983: Why blocks make Ruby methods 439% slower ?
https://bugs.ruby-lang.org/issues/10983#change-54797
* Author: Сергей Е
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
https://www.omniref.com/ruby/2.2.0/symbols/Proc/yield#annotation=4087638&line=711&hn=1
~~~ruby
require 'benchmark/ips'
def block_call(&block)
block.call
end
def just_yield
yield
end
Benchmark.ips do |x|
x.report("call") do
block_call { 1 + 1 }
end
x.report("just yield") do
just_yield { 1 + 1 }
end
x.compare!
end
~~~
I run on Ruby 2.2.1
~~~
Calculating -------------------------------------
call 40.754k i/100ms
just yield 69.031k i/100ms
-------------------------------------------------
call 814.929k (± 4.0%) i/s - 4.075M
just yield 2.871M (±25.1%) i/s - 12.909M
Comparison:
just yield: 2871127.3 i/s
call: 814929.3 i/s - 3.52x slower
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-11-10 5:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <redmine.issue-10983.20150319090344@ruby-lang.org>
2015-03-19 9:03 ` [ruby-core:68558] [Ruby trunk - Misc #10983] [Open] Why blocks make Ruby methods 439% slower ? Sergey.V.Ezhov
2015-03-19 10:12 ` [ruby-core:68559] [Ruby trunk - Misc #10983] " ko1
2015-11-10 6:21 ` [ruby-core:71428] " nobu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).