//! Returns total number of microseconds truncating any sub microsecond values tick_type total_microseconds() const { if (ticks_per_second() < 1000000) { return ticks() * (static_cast<tick_type>(1000000) / ticks_per_second()); } return ticks() / (ticks_per_second() / static_cast<tick_type>(1000000)) ; }
statistics_bridge::statistics_bridge(calls_collector_i &collector, const overhead &overhead_, ipc::channel &frontend, const std::shared_ptr<module_tracker> &module_tracker_) : _analyzer(overhead_.external), _collector(collector), _frontend(frontend), _module_tracker(module_tracker_) { initialization_data idata = { get_current_executable(), ticks_per_second() }; send(init, idata); }
void IntervalTimer::enable() { if (dont_use_any_timer) return; // no timers wanted if (dont_use_real_timer && sig == SIGALRM) return; // don't install real timer if (!check_and_pre_enable()) return; static struct itimerval dt; // value for activating timer dt.it_value.tv_sec = dt.it_interval.tv_sec = 0; dt.it_value.tv_usec = dt.it_interval.tv_usec = 1000000 / ticks_per_second() / oversample_rate; struct sigaction action; # if TARGET_OS_VERSION == SOLARIS_VERSION \ || TARGET_OS_VERSION == MACOSX_VERSION \ || TARGET_OS_VERSION == LINUX_VERSION action.sa_sigaction = (void (*)(int, siginfo_t*, void*)) IntervalTimerTick; # elif COMPILER != GCC_COMPILER && TARGET_OS_VERSION == SUNOS_VERSION action.sa_handler = (void (*)()) IntervalTimerTick; # else # error which? # endif action.sa_flags = SignalInterface::install_flags(); sigfillset(&action.sa_mask); # if GENERATE_DEBUGGING_AIDS if (CheckAssertions) { sigdelset(&action.sa_mask, SIGINT); sigdelset(&action.sa_mask, SIGTSTP); sigdelset(&action.sa_mask, SIGTRAP); } # endif sigdelset(&action.sa_mask, SIGILL); sigdelset(&action.sa_mask, SIGFPE); sigdelset(&action.sa_mask, SIGSEGV); if (sigaction( sig, &action, NULL) == -1) { perror("sigaction"); fatal1("couldn't install signal handler for signal %ld", sig); } if (!sigismember(&action.sa_mask, sig) || !sigismember(&SignalInterface::sig_mask, sig)) fatal1("should have masked %d", sig); if (setitimer(timer, &dt, NULL)) fatal("cannot start timer!"); post_enable(); }
//! Returns normalized number of seconds (0..60) sec_type seconds() const { return static_cast<sec_type>((ticks()/ticks_per_second()) % 60); }
//! Returns normalized number of minutes min_type minutes() const { return static_cast<min_type>((ticks() / (60*ticks_per_second())) % 60); }
//! Returns number of hours in the duration hour_type hours() const { return static_cast<hour_type>(ticks() / (3600*ticks_per_second())); }
//! Returns count of fractional seconds at given resolution fractional_seconds_type fractional_seconds() const { return (ticks() % ticks_per_second()); }
//! Returns total number of seconds truncating any fractional seconds sec_type total_seconds() const { return static_cast<sec_type>(ticks() / ticks_per_second()); }
void IntervalTimer::enroll_sync(float freq, doFn fn) { TimerEntry* e = alloc_entry(); int32 factor = (int32) rint(float(ticks_per_second()) / freq); e->initialize(fn, (doFn)-1, factor); }