mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
30 lines
504 B
YAML
30 lines
504 B
YAML
|
prelude: |
|
||
|
class C
|
||
|
attr_accessor :x
|
||
|
def initialize
|
||
|
@x = nil
|
||
|
end
|
||
|
class_eval <<-END
|
||
|
def ar
|
||
|
#{'x;'*256}
|
||
|
end
|
||
|
def aw
|
||
|
#{'self.x = nil;'*256}
|
||
|
end
|
||
|
def arm
|
||
|
m = method(:x)
|
||
|
#{'m.call;'*256}
|
||
|
end
|
||
|
def awm
|
||
|
m = method(:x=)
|
||
|
#{'m.call(nil);'*256}
|
||
|
end
|
||
|
END
|
||
|
end
|
||
|
obj = C.new
|
||
|
benchmark:
|
||
|
attr_reader: "obj.ar"
|
||
|
attr_writer: "obj.aw"
|
||
|
attr_reader_method: "obj.arm"
|
||
|
attr_writer_method: "obj.awm"
|