unix/cputime.c: Cache sc_clk_tck and check it for sanity.
This commit is contained in:
parent
69aee43fa6
commit
68581b009f
2 changed files with 13 additions and 1 deletions
|
@ -9,7 +9,14 @@ grub_uint64_t
|
|||
grub_util_get_cpu_time_ms (void)
|
||||
{
|
||||
struct tms tm;
|
||||
static long sc_clk_tck;
|
||||
if (!sc_clk_tck)
|
||||
{
|
||||
sc_clk_tck = sysconf(_SC_CLK_TCK);
|
||||
if (sc_clk_tck <= 0)
|
||||
sc_clk_tck = 1000;
|
||||
}
|
||||
|
||||
times (&tm);
|
||||
return (tm.tms_utime * 1000ULL) / sysconf(_SC_CLK_TCK);
|
||||
return (tm.tms_utime * 1000ULL) / sc_clk_tck;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue