Skip to content

Commit 368ba26

Browse files
authored
Create working_with_profiler.rb
1 parent e22ab2c commit 368ba26

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

0 Basics/working_with_profiler.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require "profile"
2+
3+
class Peter
4+
5+
def initialize(amt)
6+
@value = amt
7+
end
8+
9+
def rob(amt)
10+
@value -= amt
11+
amt
12+
end
13+
end
14+
15+
class Paul
16+
def initialize
17+
@value = 0
18+
end
19+
20+
def pay(amt)
21+
@value += amt
22+
amt
23+
end
24+
end
25+
26+
if __FILE__ == $0
27+
peter = Peter.new(1000)
28+
paul = Paul.new
29+
1000.times do
30+
paul.pay(peter.rob(10))
31+
end
32+
end

0 commit comments

Comments
 (0)