Use a 64 bit long as a tick counter instead of clock_gettime. Use a memory buffer and only dump data through SIGUSR1.