From: Ilmari Heikkinen Date: 2006-07-11T19:38:13+09:00 Subject: Re: [ANN] ruby-opengl ------=_Part_57693_15079829.1152614289413 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, On 7/9/06, Bill Kelly wrote: > require 'opengl' > > class Object > (GL.methods - Object.methods).each do |m| > define_method("gl#{m}") {|*args| GL.send(m, *args)} > end > > (GLU.methods - Object.methods).each do |m| > define_method("glu#{m}") {|*args| GLU.send(m, *args)} > end > end #define_method makes somewhat slower methods than alias_method. If an app is making lots of GL calls, it might cause some slowdown. I doubt it makes much change in real applications, but here's a silly micro-benchmark anyhow: $ ruby bench_alias_define.rb user system total real Foo 0.200000 0.030000 0.230000 ( 0.224021) FooAlias 0.190000 0.030000 0.220000 ( 0.222571) FooDelegate 0.810000 0.100000 0.910000 ( 0.909526) -- Ilmari ------=_Part_57693_15079829.1152614289413 Content-Type: application/x-ruby; name=bench_alias_define.rb Content-Transfer-Encoding: base64 X-Attachment-Id: f_epi4p0w2 Content-Disposition: attachment; filename="bench_alias_define.rb" cmVxdWlyZSAnYmVuY2htYXJrJwoKbW9kdWxlIEZvbwpleHRlbmQgc2VsZgoKICBkZWYgYmFyKHgs eSkKICAgIHggKyB5CiAgZW5kCgplbmQKCgptb2R1bGUgRm9vQWxpYXMKaW5jbHVkZSBGb28KZXh0 ZW5kIHNlbGYKCiAgRm9vLmluc3RhbmNlX21ldGhvZHMoZmFsc2UpLmVhY2h7fG1ufAogICAgYWxp YXNfbWV0aG9kICJhXyN7bW59IiwgbW4KICAgIHB1YmxpYyAiYV8je21ufSIKICB9CgplbmQKCgpt b2R1bGUgRm9vRGVsZWdhdGUKZXh0ZW5kIHNlbGYKCiAgRm9vLmluc3RhbmNlX21ldGhvZHMoZmFs c2UpLmVhY2h7fG1ufAogICAgZGVmaW5lX21ldGhvZCgiYV8je21ufSIpe3wqYXwgRm9vLnNlbmQo bW4sICphKSB9CiAgfQoKZW5kCgoKCkJlbmNobWFyay5ibXt8eHwKICB4LnJlcG9ydCgiRm9vIil7 IDEwMDAwMC50aW1lc3t8aXwgRm9vLmJhcihpLGkpIH0gfQogIHgucmVwb3J0KCJGb29BbGlhcyIp eyAxMDAwMDAudGltZXN7fGl8IEZvb0FsaWFzLmFfYmFyKGksaSkgfSB9CiAgeC5yZXBvcnQoIkZv b0RlbGVnYXRlIil7IDEwMDAwMC50aW1lc3t8aXwgRm9vRGVsZWdhdGUuYV9iYXIoaSxpKSB9IH0K fQoK ------=_Part_57693_15079829.1152614289413--