X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fltj-debug.lua;h=c9704c12dd3c0acc0eefa9145e0ac021b1927cec;hb=1379fbf6aae445cdce3906e7b83cc1c8550e78d5;hp=d4a084a24170a905d30ddf6881670ef9cafba3ce;hpb=4285693e49ee8fdf6681a1343a0e8f86a5e73511;p=luatex-ja%2Fluatexja.git diff --git a/src/ltj-debug.lua b/src/ltj-debug.lua index d4a084a..c9704c1 100644 --- a/src/ltj-debug.lua +++ b/src/ltj-debug.lua @@ -88,6 +88,7 @@ ltjdbg.pformat = pformat -------------------- 所要時間合計 require("socket") do + local max = math.max local gettime = socket.gettime local time_stat = {} local function start_time_measure(n) @@ -100,12 +101,19 @@ do end local function stop_time_measure(n) local t = time_stat[n] - t[2] = t[2] + gettime() + t[2] = max(t[2] + gettime(), 0) end local function print_measure() + local temp = {} for i,v in pairs(time_stat) do - print (i, tostring(v[1]) .. ' times', tostring(v[2]) .. ' sec.') + temp[#temp+1] = { i, v[1], v[2], v[2]/v[1] } + end + table.sort(temp, function (a,b) return (a[4]>b[4]) end) + print() + print('desc', 'ave. (us)', 'times', 'total (ms)') + for _,v in ipairs(temp) do + print ((v[1] .. ' '):sub(1,16), 1000000*v[4], v[2], 1000*v[3]) end end if luatexja.base then