Skip to content

Commit 0825576

Browse files
committed
update benchmark
1 parent 0e2018f commit 0825576

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

benchmark.rb

+19-3
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,38 @@ def base_find(char)
2525
("a".."k").find { |letter| letter == char }
2626
end
2727

28+
memoize def find_z
29+
base_find("z")
30+
end
31+
2832
memoize def find_new(char)
2933
base_find(char)
3034
end
3135
end
3236
end
3337

34-
def test_memery
38+
def test_no_args
39+
Foo.find_z
40+
end
41+
42+
def test_with_args
3543
Foo.find_new("d")
3644
end
3745

3846
Benchmark.ips do |x|
39-
x.report("test_memery") { test_memery }
47+
x.report("test_no_args") { test_no_args }
48+
end
49+
50+
Benchmark.memory do |x|
51+
x.report("test_no_args") { 100.times { test_no_args } }
52+
end
53+
54+
Benchmark.ips do |x|
55+
x.report("test_with_args") { test_with_args }
4056
end
4157

4258
Benchmark.memory do |x|
43-
x.report("test_memery") { 100.times { test_memery } }
59+
x.report("test_with_args") { 100.times { test_with_args } }
4460
end
4561

4662
puts "```"

0 commit comments

Comments
 (0)