So here are the benchmark results, and they are surprising.
tested script:
package.cpath = "./?.so"
require "hello"
for j=1,1e3 do
misc.memprof.start('./memprof.test')
misc.memprof.stop()
end
----------------------------------------------------------
vanilla:
0,03s user 0,05s system 50% cpu 0,158 total
0,01s user 0,04s system 88% cpu 0,051 total
0,01s user 0,05s system 79% cpu 0,071 total
avg total: 0.093
avg total per memprof.start/stop: 9.3e-5
performance relative to vanilla: x1
----------------------------------------------------------
dump only shared objects addresses and names:
18,83s user 0,36s system 99% cpu 19,285 total
19,15s user 0,35s system 99% cpu 19,586 total
18,75s user 0,39s system 99% cpu 19,244 total
avg total: 19.371
avg total per memprof.start/stop: 0.019
performance relative to vanilla: x208.29
----------------------------------------------------------
dump all symbols:
0,30s user 0,10s system 75% cpu 0,519 total
0,41s user 0,20s system 52% cpu 1,173 total
0,31s user 0,08s system 73% cpu 0,531 total
avg total: 0.741
avg total per memprof.start/stop: 7.4e-4
performance relative to vanilla: x7.96
==========================================================