Recently, I often embed the performance measurement log and disable it every time, so I decided to make a library. I made it so much, so a memorandum.
2017/4/23 Corrected because there was a difference in type definition && configure
If you use it with a printf image, it will save a log with the time. The log is not output immediately when the function is executed, but is saved in the reserved memory and then discharged at the end.
Since the log is not spit out each time the process is executed, the log is spit out with memcpy, so I think that the effect on speed is less than simply inserting the log. I think that it can be used enough if it is an application level of middleware.
The basics are as follows.
timetestlog.h
void * timetestlog_init(char *delimiter, size_t maxloglen, unsigned long maxstoresize);
int timetestlog_store_printf(void * handle, const char *format, ...);
void timetestlog_exit(void * handle);
timetestlog_init: initialization function - input --delimiter [in] It is possible to specify the delimiter between timestamp logs. If NULL, "". --maxloglen [in] Maximum length of one output log line. Logs longer than this length will be truncated. --maxstoresize [in] Maximum number of logs to store. More logs than this number will be truncated. - return --Hand to be used in the subsequent API. NULL is an error
timetestlog_store_printf: Log save function. Just specify the handle obtained by timetestlog_init in the first argument of printf.
timetestlog_exit: Exit function. Specify the handle obtained by timetestlog_init.
It is listed on github below. https://github.com/developer-kikikaikai/speedtest
After cloning or downloading the code
cd speedtest/lib
make
Build with. Libtimelog.so and libtimelog.a will be created in the same folder.
Confirmed to work on Ubuntu 14.04 Desktop 64bit I think it will work on Linux OS.
-Although I am careful to have a small overhead such as allocate only at init, I do not care about the overhead for ordinary functions such as va_start and memcpy.
Recommended Posts