mirror of
https://github.com/gperftools/gperftools
synced 2025-02-02 04:31:33 +00:00
Unbreak profiling with CPUPROFILE_FREQUENCY=1
This closes ticket #777. No test sadly, since it's not trivial to unittest this case. But fix with single-shot manual testing is better than nothing.
This commit is contained in:
parent
6ff86ff6a7
commit
6682016092
@ -492,8 +492,10 @@ void ProfileHandler::UpdateTimer(bool enable) {
|
||||
timer_running_ = enable;
|
||||
|
||||
struct itimerval timer;
|
||||
timer.it_interval.tv_sec = 0;
|
||||
timer.it_interval.tv_usec = (enable ? (1000000 / frequency_) : 0);
|
||||
static const int kMillion = 1000000;
|
||||
int interval_usec = enable ? kMillion / frequency_ : 0;
|
||||
timer.it_interval.tv_sec = interval_usec / kMillion;
|
||||
timer.it_interval.tv_usec = interval_usec % kMillion;
|
||||
timer.it_value = timer.it_interval;
|
||||
setitimer(timer_type_, &timer, 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user