swap Time::HiRes usleep for nanosleep for platform compatibility