Skip to content

Commit

Permalink
nano is 10^9 (profiling, fix #7720)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Jul 28, 2014
1 parent 8b743d1 commit 0daeb41
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ static volatile size_t bt_size_max = 0;
static volatile size_t bt_size_cur = 0;
static volatile u_int64_t nsecprof = 0;
static volatile int running = 0;
static const u_int64_t GIGA = 1000000000ULL;
/////////////////////////////////////////
// Timers to take samples at intervals //
/////////////////////////////////////////
Expand All @@ -34,7 +35,7 @@ static DWORD WINAPI profile_bt( LPVOID lparam )
}
while (1) {
if (running && bt_size_cur < bt_size_max) {
DWORD timeout = nsecprof/1000000;
DWORD timeout = nsecprof/GIGA;
timeout = min(max(timeout,tc.wPeriodMin*2),tc.wPeriodMax/2);
Sleep(timeout);
if ((DWORD)-1 == SuspendThread(hMainThread)) {
Expand Down Expand Up @@ -266,8 +267,8 @@ DLLEXPORT int jl_profile_start_timer(void)
profile_started = 1;
}

timerprof.tv_sec = nsecprof/1000000;
timerprof.tv_nsec = nsecprof%1000000;
timerprof.tv_sec = nsecprof/GIGA;
timerprof.tv_nsec = nsecprof%GIGA;

running = 1;
ret = clock_alarm(clk, TIME_RELATIVE, timerprof, profile_port);
Expand Down Expand Up @@ -323,9 +324,9 @@ DLLEXPORT int jl_profile_start_timer(void)
if (sigaction(SIGPROF, &sa, NULL) == -1)
return -1;

timerprof.it_interval.tv_sec = nsecprof/1000000;
timerprof.it_interval.tv_sec = nsecprof/GIGA;
timerprof.it_interval.tv_usec = (nsecprof/1000)%1000;
timerprof.it_value.tv_sec = nsecprof/1000000;
timerprof.it_value.tv_sec = nsecprof/GIGA;
timerprof.it_value.tv_usec = (nsecprof/1000)%1000;
if (setitimer(ITIMER_PROF, &timerprof, 0) == -1)
return -3;
Expand Down Expand Up @@ -399,10 +400,10 @@ DLLEXPORT int jl_profile_start_timer(void)
return -2;

// Start the timer
itsprof.it_interval.tv_sec = nsecprof/1000000;
itsprof.it_interval.tv_nsec = nsecprof%1000000;
itsprof.it_value.tv_sec = nsecprof/1000000;
itsprof.it_value.tv_nsec = nsecprof%1000000;
itsprof.it_interval.tv_sec = nsecprof/GIGA;
itsprof.it_interval.tv_nsec = nsecprof%GIGA;
itsprof.it_value.tv_sec = nsecprof/GIGA;
itsprof.it_value.tv_nsec = nsecprof%GIGA;
if (timer_settime(timerprof, 0, &itsprof, NULL) == -1)
return -3;

Expand Down

0 comments on commit 0daeb41

Please sign in to comment.