From: Bill Kelly Date: 2006-07-12T00:58:33+09:00 Subject: Re: [ANN] ruby-opengl From: "Ilmari Heikkinen" > #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) > module Foo > extend self > > def bar(x,y) > x + y > end > > end > > > module FooAlias > include Foo > extend self > > Foo.instance_methods(false).each{|mn| > alias_method "a_#{mn}", mn > public "a_#{mn}" > } > > end Sweet. I learned about three new tricks from that. :D Thanks, Bill