diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-16 23:34:37 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-16 23:34:37 +0000 |
commit | 38340a5a34fa98a39b3946414e8ffe2f5e91dfab (patch) | |
tree | 55697363b52d70a126ee6e6d1148cd5752674bef /ChangeLog | |
parent | 9c7f2181e0f95002bf88deea358b6063813f0ef3 (diff) | |
download | ruby-38340a5a34fa98a39b3946414e8ffe2f5e91dfab.tar.gz |
socket: Socket#connect_nonblock avoids arg parsing with C API
* ext/socket/socket.c (sock_connect_nonblock):
avoid argument parsing in C.
[ruby-core:71439] [Feature #11339]
* ext/socket/lib/socket.rb (Socket#connect_nonblock):
new wrapper for private method, move RDoc
target 0: a (ruby 2.3.0dev (2015-11-12 trunk 52540) [x86_64-linux])
target 1: b (ruby 2.3.0dev (2015-11-12 avoid-kwarg-capi 52540) [x86_64-linux]
-----------------------------------------------------------
connect_nonblock
require 'tempfile'
require 'socket'
require 'io/wait'
nr = 500000
Tempfile.create(%w(connect_nonblock .sock)) do |tmp|
path = tmp.path
File.unlink(path)
s = UNIXServer.new(path)
addr = Socket.sockaddr_un(path).freeze
nr.times do
c = Socket.new(Socket::AF_UNIX, Socket::SOCK_STREAM)
while c.connect_nonblock(addr, exception: false) == :wait_writable
c.wait_writable
end
s.accept.close
c.close
end
end
-----------------------------------------------------------
raw data:
[["connect_nonblock",
[[4.014209181070328,
3.8479955345392227,
3.981342639774084,
4.471840236335993,
3.7867715656757355],
[3.639054525643587,
3.58337214961648,
3.525284394621849,
3.52646067738533,
3.511393066495657]]]]
Elapsed time: 37.889623996 (sec)
-----------------------------------------------------------
benchmark results:
minimum results in each 5 measurements.
Execution time (sec)
name a b
connect_nonblock 3.787 3.511
Speedup ratio: compare with the result of `a' (greater is better)
name b
connect_nonblock 1.078
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ChangeLog')
-rw-r--r-- | ChangeLog | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -1,3 +1,11 @@ +Tue Nov 17 08:25:57 2015 Eric Wong <e@80x24.org> + + * ext/socket/socket.c (sock_connect_nonblock): + avoid argument parsing in C. + [ruby-core:71439] [Feature #11339] + * ext/socket/lib/socket.rb (Socket#connect_nonblock): + new wrapper for private method, move RDoc + Tue Nov 17 08:16:09 2015 Eric Wong <e@80x24.org> * ext/socket/init.c (rsock_s_recvfrom_nonblock): |