blob: b9c706157138fffe57e8716ab3c540c09acb11c5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
require 'rubinius/agent'
module ActiveSupport
module Testing
module Performance
protected
def run_gc
GC.run(true)
end
module Metrics
class Base
attr_reader :loopback
# TODO
def profile
yield
end
protected
# overridden by each implementation
def with_gc_stats
@loopback = Rubinius::Agent.loopback
GC.run(true)
yield
end
end
class Time < Base; end
class ProcessTime < Time
# unsupported
def measure; 0; end
end
class WallTime < Time
def measure
super
end
end
class CpuTime < Time
# unsupported
def measure; 0; end
end
class Memory < Base
def measure
loopback.get("system.memory.counter.bytes").last
end
end
class Objects < Amount
def measure
loopback.get("system.memory.counter.objects").last
end
end
class GcRuns < Amount
def measure
loopback.get("system.gc.full.count").last + loopback.get("system.gc.young.count").last
end
end
class GcTime < Time
def measure
(loopback.get("system.gc.full.wallclock").last + loopback.get("system.gc.young.wallclock").last) / 1000.0
end
end
end
end
end
end
|