-
Notifications
You must be signed in to change notification settings - Fork 40
Profiling, Code Coverage, Debugging, Unused code
Patrick Hammer edited this page May 22, 2024
·
4 revisions
time ./NAR shell < ./examples/nal/example1.nal
Events in example: 220
Timing result: 4.73s
Used CPU: M2 CPU
Event throughput: ~ 47 events per second on average.
Commit: 00606f9af2c8431c9ac5f365da415c8bc5b8bf3d
./build.sh -pg
now run NAR, and after it's done:
gprof NAR gmon.out > analysis.txt
Profiling can significantly help to increase performance. For instance, term comparison via for loop versus memcmp revealed:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
49.18 0.30 0.30 70549890 0.00 0.00 Term_Equal
26.23 0.46 0.16 15086 0.01 0.04 Memory_addEvent
6.56 0.50 0.04 17221989 0.00 0.00 Event_Equal
4.92 0.53 0.03 1308239 0.00 0.00 Term_ExtractSubterm
3.28 0.55 0.02 15513 0.00 0.04 RuleTable_Apply
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
48.15 0.13 0.13 70549890 0.00 0.00 Term_Equal
18.52 0.18 0.05 15086 0.00 0.01 Memory_addEvent
7.41 0.20 0.02 17221989 0.00 0.00 Event_Equal
7.41 0.22 0.02 15513 0.00 0.02 RuleTable_Apply
3.70 0.23 0.01 1308239 0.00 0.00 Term_ExtractSubterm
./build.sh --coverage
now run NAR tests, and after it's done:
gcov filename.c
now look at filename.c.gcov
./build.sh
gdb
file NAR
run args
if for some reason there is a segfault, type the following to print the stacktrace:
backtrace
The following command helps to detects both unused code and methods which should probably be static (module specific):
./build -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--print-gc-sections