mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 20:44:20 +00:00
This follows the same approach used for attr_reader/attr_writer in 2d98593bf54a37397c6e4886ccc7e3654c2eaf85, skipping the checking for tracing after the first call using the call cache, and clearing the call cache when tracing is turned on/off. Fixes [Bug #18886]
26 lines
460 B
YAML
26 lines
460 B
YAML
prelude: |
|
|
C = Struct.new(:x) do
|
|
class_eval <<-END
|
|
def r
|
|
#{'x;'*256}
|
|
end
|
|
def w
|
|
#{'self.x = nil;'*256}
|
|
end
|
|
def rm
|
|
m = method(:x)
|
|
#{'m.call;'*256}
|
|
end
|
|
def wm
|
|
m = method(:x=)
|
|
#{'m.call(nil);'*256}
|
|
end
|
|
END
|
|
end
|
|
obj = C.new(nil)
|
|
benchmark:
|
|
member_reader: "obj.r"
|
|
member_writer: "obj.w"
|
|
member_reader_method: "obj.rm"
|
|
member_writer_method: "obj.wm"
|