summaryrefslogtreecommitdiff
path: root/scripts/context/lua/mtx-profile.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2012-11-26 19:00:25 +0200
committerMarius <mariausol@gmail.com>2012-11-26 19:00:25 +0200
commit48c4609c92a6e0cbbbd8c5e894d2e11b081e032f (patch)
tree6fd604c2644afd46971a42f42ce3e1a276c19883 /scripts/context/lua/mtx-profile.lua
parent7bd57701b696956d241d5f3fec8cc6288082cf5c (diff)
downloadcontext-48c4609c92a6e0cbbbd8c5e894d2e11b081e032f.tar.gz
beta 2012.11.26 13:31
Diffstat (limited to 'scripts/context/lua/mtx-profile.lua')
-rw-r--r--scripts/context/lua/mtx-profile.lua35
1 files changed, 15 insertions, 20 deletions
diff --git a/scripts/context/lua/mtx-profile.lua b/scripts/context/lua/mtx-profile.lua
index 74e1d1538..35cf1fc47 100644
--- a/scripts/context/lua/mtx-profile.lua
+++ b/scripts/context/lua/mtx-profile.lua
@@ -41,33 +41,28 @@ function scripts.profiler.analyze(filename)
if f then
local times, counts, calls = { }, { }, { }
local totalruntime, totalcount, totalcalls = 0, 0, 0
- while true do
- local line = f:read()
- if line then
- local stacklevel, filename, functionname, linenumber, currentline, localtime, totaltime = line:match("^(%d+)\t(.-)\t(.-)\t(.-)\t(.-)\t(.-)\t(.-)")
- if not filename then
- -- next
- elseif filename == "=[C]" then
- if not functionname:find("^%(") then
- calls[functionname] = (calls[functionname] or 0) + 1
- end
- else
- local filename = filename:match("^@(.*)$")
- if filename then
- local fi = times[filename]
- if not fi then fi = { } times[filename] = fi end
- fi[functionname] = (fi[functionname] or 0) + tonumber(localtime)
- counts[functionname] = (counts[functionname] or 0) + 1
- end
+ for line in f:lines() do
+ local stacklevel, filename, functionname, linenumber, currentline, localtime, totaltime = line:match("^(%d+)\t(.-)\t(.-)\t(.-)\t(.-)\t(.-)\t(.-)")
+ if not filename then
+ -- next
+ elseif filename == "=[C]" then
+ if not functionname:find("^%(") then
+ calls[functionname] = (calls[functionname] or 0) + 1
end
else
- break
+ local filename = filename:match("^@(.*)$")
+ if filename then
+ local fi = times[filename]
+ if not fi then fi = { } times[filename] = fi end
+ fi[functionname] = (fi[functionname] or 0) + tonumber(localtime)
+ counts[functionname] = (counts[functionname] or 0) + 1
+ end
end
end
f:close()
print("")
local loaded = { }
- sortedtable.sortedkeys(times)
+ local sorted = table.sortedkeys(times)
for i=1,#sorted do
local filename = sorted[i]
local functions = times[filename]