ADDING_STATS.txt   [plain text]


Steps to add a statistic
========================

1. Define an enum value in statistic.h, such as STATISTIC_FOO.

2. In statistic.c add an entry to to the statistic_name_map.

3. In preferences.c add .array[N] = STATISTIC_FOO to .display_stats.

4. In preferences.c add the symbolic name(s) for the statistic to stat_map.

5. Add the metric to the keys in the usage statement.

6. In top.c you should add the type to the sort function, if needed.

7. In the top.1 man page, add a description of the statistic.

8. Create or extend one of the .c files and add it to the Xcode project.

    You could start by copying user.c and user.h.

9. Add a test for the statistic to the stats_option test in tests/test_top.c.
10. Update userinput_help.c if your change affects a runtime option.