critique 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/critique/profiling.rb +21 -17
- data/lib/critique/version.rb +1 -1
- metadata +13 -13
data/lib/critique/profiling.rb
CHANGED
@@ -28,29 +28,32 @@ module Critique
|
|
28
28
|
before = stack.pop
|
29
29
|
after = system_usage
|
30
30
|
|
31
|
-
info(([label, '<--', filler(label)] + pretty(after
|
31
|
+
info(([label, '<--', filler(label)] + pretty(after)).join(' '))
|
32
32
|
|
33
33
|
padding(:-)
|
34
34
|
end
|
35
35
|
|
36
36
|
private
|
37
37
|
|
38
|
-
def pretty(
|
39
|
-
used =
|
40
|
-
free =
|
38
|
+
def pretty(stats, diff_with = nil)
|
39
|
+
used = stats[0]
|
40
|
+
free = stats[1]
|
41
|
+
swap = stats[2]
|
41
42
|
result = [
|
42
43
|
sprintf("used: %.2f GB", used / conversion_gb),
|
43
|
-
sprintf("free: %.2f GB", free / conversion_gb)
|
44
|
+
sprintf("free: %.2f GB", free / conversion_gb),
|
45
|
+
sprintf("swap: %.2f GB", swap / conversion_gb)
|
44
46
|
]
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
# WIP:
|
49
|
+
# if diff_with
|
50
|
+
# current = used
|
51
|
+
# previous = diff_with[0]
|
52
|
+
# bytes = (current - previous).to_f
|
53
|
+
# percent = (bytes / previous) * 100
|
54
|
+
#
|
55
|
+
# result.push(sprintf("delta: %+.2f%", percent))
|
56
|
+
# end
|
54
57
|
|
55
58
|
result
|
56
59
|
end
|
@@ -70,16 +73,17 @@ module Critique
|
|
70
73
|
# installed = `sysctl -n hw.memsize`.to_i / conversion_gb
|
71
74
|
|
72
75
|
stats = `vm_stat`.split("\n")
|
73
|
-
used = add_stats(stats, 'wired down', 'active', 'inactive')
|
74
|
-
free = add_stats(stats, 'free', 'speculative')
|
76
|
+
used = add_stats(stats, 'Pages wired down', 'Pages active', 'Pages inactive')
|
77
|
+
free = add_stats(stats, 'Pages free', 'Pages speculative')
|
78
|
+
swap = add_stats(stats, 'Pageouts')
|
75
79
|
|
76
|
-
[used, free]
|
80
|
+
[used, free, swap]
|
77
81
|
end
|
78
82
|
|
79
83
|
def add_stats(*args)
|
80
84
|
stats = args.shift
|
81
85
|
keys = args
|
82
|
-
matches = stats.select { |s| keys.any? { |k| s =~
|
86
|
+
matches = stats.select { |s| keys.any? { |k| s =~ /#{k}:/ } }
|
83
87
|
values = matches.map { |m| m.split(/\s+/).last.to_i * conversion_paging }.inject(0, :+)
|
84
88
|
end
|
85
89
|
|
data/lib/critique/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: critique
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70169926773220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70169926773220
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70169926772740 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70169926772740
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70169926772280 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70169926772280
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rr
|
49
|
-
requirement: &
|
49
|
+
requirement: &70169926771800 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70169926771800
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &70169926771340 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70169926771340
|
69
69
|
description: critiques your code
|
70
70
|
email:
|
71
71
|
- corey@coolerator.net
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
segments:
|
110
110
|
- 0
|
111
|
-
hash: -
|
111
|
+
hash: -3723307256638907563
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project:
|
114
114
|
rubygems_version: 1.8.11
|