diff options
author | Mike Pall <mike> | 2013-09-09 02:27:41 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2013-09-09 04:26:12 +0200 |
commit | 1fd2048c8d296e7bde3e27b8ec1fc5b2ea834d3c (patch) | |
tree | 4fe830c02eaeb247ce1dace847c9454463026aef | |
parent | cb336995a8b1af7efade1aec543b3624f59c2570 (diff) | |
download | luajit-1fd2048c8d296e7bde3e27b8ec1fc5b2ea834d3c.tar.gz luajit-1fd2048c8d296e7bde3e27b8ec1fc5b2ea834d3c.tar.bz2 luajit-1fd2048c8d296e7bde3e27b8ec1fc5b2ea834d3c.zip |
Switch from -jp=n<top_n> to -jp=m<min_pct> as a threshold.
-rw-r--r-- | src/jit/p.lua | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/jit/p.lua b/src/jit/p.lua index 75d93215..90b50bca 100644 --- a/src/jit/p.lua +++ b/src/jit/p.lua | |||
@@ -32,7 +32,7 @@ | |||
32 | -- z Show zones. Can be combined with stack dumps, e.g. zf or fz. | 32 | -- z Show zones. Can be combined with stack dumps, e.g. zf or fz. |
33 | -- r Show raw sample counts. Default: show percentages. | 33 | -- r Show raw sample counts. Default: show percentages. |
34 | -- G Produce output suitable for graphical tools (e.g. flame graphs). | 34 | -- G Produce output suitable for graphical tools (e.g. flame graphs). |
35 | -- n<number> Show top N samples. Default: 10. | 35 | -- m<number> Minimum sample percentage to be shown. Default: 3. |
36 | -- i<number> Sampling interval in milliseconds. Default: 10. | 36 | -- i<number> Sampling interval in milliseconds. Default: 10. |
37 | -- | 37 | -- |
38 | ---------------------------------------------------------------------------- | 38 | ---------------------------------------------------------------------------- |
@@ -53,7 +53,7 @@ local out | |||
53 | ------------------------------------------------------------------------------ | 53 | ------------------------------------------------------------------------------ |
54 | 54 | ||
55 | local prof_ud | 55 | local prof_ud |
56 | local prof_states, prof_split, prof_maxn, prof_raw, prof_fmt, prof_depth | 56 | local prof_states, prof_split, prof_min, prof_raw, prof_fmt, prof_depth |
57 | local prof_count1, prof_count2, prof_samples | 57 | local prof_count1, prof_count2, prof_samples |
58 | 58 | ||
59 | local map_vmmode = { | 59 | local map_vmmode = { |
@@ -121,11 +121,13 @@ local function prof_top(count1, count2, samples, indent) | |||
121 | end | 121 | end |
122 | sort(t, function(a, b) return count1[a] > count1[b] end) | 122 | sort(t, function(a, b) return count1[a] > count1[b] end) |
123 | local raw = prof_raw | 123 | local raw = prof_raw |
124 | for i=1,min(n, prof_maxn) do | 124 | for i=1,n do |
125 | local k = t[i] | 125 | local k = t[i] |
126 | local v = count1[k] | 126 | local v = count1[k] |
127 | local pct = floor(v*100/samples + 0.5) | ||
128 | if pct < prof_min then break end | ||
127 | if not raw then | 129 | if not raw then |
128 | out:write(format("%s%2d%% %s\n", indent, floor(v*100/samples + 0.5), k)) | 130 | out:write(format("%s%2d%% %s\n", indent, pct, k)) |
129 | elseif raw == "r" then | 131 | elseif raw == "r" then |
130 | out:write(format("%s%5d %s\n", indent, v, k)) | 132 | out:write(format("%s%5d %s\n", indent, v, k)) |
131 | else | 133 | else |
@@ -162,8 +164,8 @@ end | |||
162 | local function prof_start(mode) | 164 | local function prof_start(mode) |
163 | local interval = "" | 165 | local interval = "" |
164 | mode = mode:gsub("i%d*", function(s) interval = s; return "" end) | 166 | mode = mode:gsub("i%d*", function(s) interval = s; return "" end) |
165 | prof_maxn = 10 | 167 | prof_min = 3 |
166 | mode = mode:gsub("n(%d+)", function(s) prof_maxn = tonumber(s); return "" end) | 168 | mode = mode:gsub("m(%d+)", function(s) prof_min = tonumber(s); return "" end) |
167 | prof_depth = 1 | 169 | prof_depth = 1 |
168 | mode = mode:gsub("%-?%d+", function(s) prof_depth = tonumber(s); return "" end) | 170 | mode = mode:gsub("%-?%d+", function(s) prof_depth = tonumber(s); return "" end) |
169 | local m = {} | 171 | local m = {} |
@@ -184,7 +186,7 @@ local function prof_start(mode) | |||
184 | prof_fmt = flags..scope.."Z;" | 186 | prof_fmt = flags..scope.."Z;" |
185 | prof_depth = -100 | 187 | prof_depth = -100 |
186 | prof_raw = true | 188 | prof_raw = true |
187 | prof_maxn = 2147483647 | 189 | prof_min = 0 |
188 | elseif scope == "" then | 190 | elseif scope == "" then |
189 | prof_fmt = false | 191 | prof_fmt = false |
190 | else | 192 | else |