//TODO obviously not (really) threadsafe void DspComponent::progress_(float p) { static int last = 0; static struct timespec last_time = {0,0}; struct timespec now; #ifdef _MSC_VER static LARGE_INTEGER frequency; if (!frequency.QuadPart) QueryPerformanceFrequency(&frequency); LARGE_INTEGER count; long long int ns; QueryPerformanceCounter(&count); /* Total nano seconds from a starting point. */ ns = (double)count.QuadPart / frequency.QuadPart * 1000000000; now.tv_sec = count.QuadPart / frequency.QuadPart; now.tv_nsec = ns % 1000000000; #elif __MACH__ now = orwl_gettime(); #else clock_gettime(CLOCK_MONOTONIC, &now); #endif #pragma omp critical (printprogress_timed) if (p == 0.0 || p == 1.0 || now.tv_sec != last_time.tv_sec || now.tv_nsec - last_time.tv_nsec >= 1000000000/4) { last_time = now; if (_prog_callback) _prog_callback(this, p, _prog_data); else if (p == 1.0) printprogress(p*1000, 1000, last, " %s\n", _componentName.c_str()); else printprogress(p*1000, 1000, last, " %s", _componentName.c_str()); } }
icp_time_t gettime(void) { struct timespec t = orwl_gettime(); local_time_ns = (t.tv_sec / ORWL_GIGA) + t.tv_nsec; local_time_ms = (icp_time_t) (local_time_ns * ORWL_NANO2MILLI); return local_time_ms; }
char *gettime_s(void) { struct timespec t = orwl_gettime(); sprintf(result, "%lu.%09lu sec", t.tv_sec, t.tv_nsec); sprintf(result, ""); return result; }