Commit 0825576 1 parent 0e2018f commit 0825576 Copy full SHA for 0825576
File tree 1 file changed +19
-3
lines changed
1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -25,22 +25,38 @@ def base_find(char)
25
25
( "a" .."k" ) . find { |letter | letter == char }
26
26
end
27
27
28
+ memoize def find_z
29
+ base_find ( "z" )
30
+ end
31
+
28
32
memoize def find_new ( char )
29
33
base_find ( char )
30
34
end
31
35
end
32
36
end
33
37
34
- def test_memery
38
+ def test_no_args
39
+ Foo . find_z
40
+ end
41
+
42
+ def test_with_args
35
43
Foo . find_new ( "d" )
36
44
end
37
45
38
46
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 }
40
56
end
41
57
42
58
Benchmark . memory do |x |
43
- x . report ( "test_memery " ) { 100 . times { test_memery } }
59
+ x . report ( "test_with_args " ) { 100 . times { test_with_args } }
44
60
end
45
61
46
62
puts "```"
You can’t perform that action at this time.
0 commit comments