summaryrefslogtreecommitdiff
path: root/ext/socket/basicsocket.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-17 01:05:30 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-17 01:05:30 +0000
commiteda2441b5354829bea9225a99e0b96f0ba40b7ab (patch)
tree6eca4779f256042dab98c3f20b28597be448cc27 /ext/socket/basicsocket.c
parent416c50f574fe9d13357b184c415c1bcda7c9e1eb (diff)
socket: avoid arg parsing in bsock_sendmsg_internal
* ext/socket/ancdata.c (bsock_sendmsg_internal): avoid arg parsing [ruby-core:71439] [Feature #11339] (rsock_bsock_sendmsg): make private, adjust for above (rsock_bsock_sendmsg_nonblock): ditto * ext/socket/rubysocket.h: adjust prototypes (rsock_opt_false_p): remove * ext/socket/basicsocket.c (rsock_init_basicsocket): define private methods * ext/socket/lib/socket.rb (BasicSocket#sendmsg): new wrapper (BasicSocket#sendmsg_nonblock): ditto target 0: a (ruby 2.3.0dev (2015-11-12 trunk 52550) [x86_64-linux]) target 1: b (ruby 2.3.0dev (2015-11-12 avoid-kwarg-capi 52550) [x86_64-linux] ----------------------------------------------------------- sendmsg_nonblock require 'socket' nr = 1_000_000 i = 0 msg = '.' buf = '.' begin r, w = UNIXSocket.pair(:SEQPACKET) while i < nr i += 1 w.sendmsg_nonblock(msg, exception: false) r.recv(1, 0, buf) end ensure r.close w.close end ----------------------------------------------------------- raw data: [["sendmsg_nonblock", [[1.875997293740511, 1.8452614955604076, 1.8449317328631878, 1.8418389447033405, 1.869386937469244], [1.5175109766423702, 1.4987873211503029, 1.4989623799920082, 1.47918451577425, 1.5017359890043736]]]] Elapsed time: 16.775453245 (sec) ----------------------------------------------------------- benchmark results: minimum results in each 5 measurements. Execution time (sec) name a b sendmsg_nonblock 1.842 1.479 Speedup ratio: compare with the result of `a' (greater is better) name b sendmsg_nonblock 1.245 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/basicsocket.c')
-rw-r--r--ext/socket/basicsocket.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/socket/basicsocket.c b/ext/socket/basicsocket.c
index 1a0120c..eef66d4 100644
--- a/ext/socket/basicsocket.c
+++ b/ext/socket/basicsocket.c
@@ -724,10 +724,11 @@ rsock_init_basicsocket(void)
rb_define_private_method(rb_cBasicSocket,
"__recv_nonblock", bsock_recv_nonblock, 4);
- rb_define_method(rb_cBasicSocket, "sendmsg", rsock_bsock_sendmsg, -1); /* in ancdata.c */
- rb_define_method(rb_cBasicSocket, "sendmsg_nonblock", rsock_bsock_sendmsg_nonblock, -1); /* in ancdata.c */
-
/* in ancdata.c */
+ rb_define_private_method(rb_cBasicSocket, "__sendmsg",
+ rsock_bsock_sendmsg, 4);
+ rb_define_private_method(rb_cBasicSocket, "__sendmsg_nonblock",
+ rsock_bsock_sendmsg_nonblock, 5);
rb_define_private_method(rb_cBasicSocket, "__recvmsg",
rsock_bsock_recvmsg, 4);
rb_define_private_method(rb_cBasicSocket, "__recvmsg_nonblock",