From 0d9d74563b5a9cec128a5e4b0b8f84bae206ab8a Mon Sep 17 00:00:00 2001 From: Joey Date: Sun, 9 Feb 2020 21:05:10 -0700 Subject: [PATCH] Update README.md --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a8b95c5..2b2f7d2 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,11 @@ main() You can see by the above code that the `notUsedProc()` can be optimized away at compile time, but the if/else statement depends on user input and cannot be optimized away. -But maybe you have a bug in the `if input == "hello"` branch but that never gets called very often or at all. This library can tell you (based on runtime usage) whether or not your branches get called and let you know. +But maybe you have a bug in the `if input == "hello"` branch but that never gets called very often or at all. This library can tell you (based on runtime usage) whether or not your branches get called and let you know. This could be useful for **test coverage** for example. ## Usage -Simply use the `findDeadCode` macro on your code, shown below, then call either or both of `printCodeUsage` or `printDeadCode`. +Simply use the `findDeadCode` macro on your code, shown below, then call either or both of `printCodeUsage` or `printDeadCode`. Or you can get the usage table itself to do with what you like via `getUsageTable`, which returns a `TableRef[string, TableRef[int, int]]` where the string is the filename and the inner table has key = lineNumber and value = timesCalled. ```nim import mort @@ -46,6 +46,10 @@ proc main() = # then call ``printCodeUsage`` and/or ``printDeadCode`` printCodeUsage() printDeadCode() + + # or get the information yourself: + let usageTable: TableRef[string, TableRef[int, int]] = getUsageTable() + # Do cool stuff, like get test coverage main() ```