unittests: Disable non-C-calls

Some benchmarks:

TRACE_EVERYTHING: 79.45s user 12.68s system 124% cpu 1:13.94  total

(default):        30.26s user  5.30s system  89% cpu   39.663 total
This commit is contained in:
ZyX
2017-04-01 13:16:25 +03:00
parent 9dd0d4f8b9
commit 708a55ee15
2 changed files with 21 additions and 7 deletions

View File

@@ -107,3 +107,7 @@ used to check how testing infrastructure works.
if tests crashed without core dump you will have no clues regarding where, but if tests crashed without core dump you will have no clues regarding where, but
this makes tests run a lot faster. Combine with `NVIM_TEST_MAIN_CDEFS` for this makes tests run a lot faster. Combine with `NVIM_TEST_MAIN_CDEFS` for
maximal speed. maximal speed.
`NVIM_TEST_TRACE_EVERYTHING` (U) (1): by default unit test only record C calls
which is faster then recording everything. Set this variable to 1 if you want to
see all traces.

View File

@@ -542,19 +542,27 @@ local function child_sethook(wr)
if os.getenv('NVIM_TEST_NO_TRACE') == '1' then if os.getenv('NVIM_TEST_NO_TRACE') == '1' then
return return
end end
local trace_only_c = (os.getenv('NVIM_TEST_TRACE_EVERYTHING') ~= '1')
local function hook(reason, lnum) local function hook(reason, lnum)
local msgchar = reason:sub(1, 1)
if reason == 'count' then
msgchar = 'C'
end
local info = nil local info = nil
if reason ~= 'tail return' then -- tail return if reason ~= 'tail return' then -- tail return
info = debug.getinfo(2, 'nSl') info = debug.getinfo(2, 'nSl')
end end
if trace_only_c and (not info or info.what ~= 'C') then
return
end
local whatchar = ' ' local whatchar = ' '
local namewhatchar = ' ' local namewhatchar = ' '
local funcname = '' local funcname = ''
local source = '' local source = ''
local msgchar = reason:sub(1, 1)
if reason == 'count' then
msgchar = 'C'
end
if info then if info then
funcname = (info.name or ''):sub(1, hook_fnamelen) funcname = (info.name or ''):sub(1, hook_fnamelen)
whatchar = info.what:sub(1, 1) whatchar = info.what:sub(1, 1)
@@ -595,9 +603,11 @@ local function child_sethook(wr)
-- eq(hook_msglen, #msg) -- eq(hook_msglen, #msg)
sc.write(wr, msg) sc.write(wr, msg)
end end
debug.sethook(hook, 'crl') debug.sethook(hook, trace_only_c and 'cr' or 'crl')
end end
local trace_end_msg = ('E%s\n'):format((' '):rep(hook_msglen - 2))
local function itp_child(wr, func) local function itp_child(wr, func)
init() init()
collectgarbage('stop') collectgarbage('stop')
@@ -606,7 +616,7 @@ local function itp_child(wr, func)
debug.sethook() debug.sethook()
collectgarbage('restart') collectgarbage('restart')
emsg = tostring(emsg) emsg = tostring(emsg)
sc.write(wr, ('E%s\n'):format((' '):rep(hook_msglen - 2))) sc.write(wr, trace_end_msg)
if not err then if not err then
if #emsg > 99999 then if #emsg > 99999 then
emsg = emsg:sub(1, 99999) emsg = emsg:sub(1, 99999)
@@ -634,7 +644,7 @@ local function check_child_err(rd)
trace[#trace + 1] = 'Partial read: <' .. trace .. '>\n' trace[#trace + 1] = 'Partial read: <' .. trace .. '>\n'
end end
end end
if traceline:sub(1, 1) == 'E' then if traceline == trace_end_msg then
break break
end end
trace[#trace + 1] = traceline trace[#trace + 1] = traceline