diff options
| author | John Polstra <jdp@FreeBSD.org> | 1996-07-30 19:00:12 +0000 |
|---|---|---|
| committer | John Polstra <jdp@FreeBSD.org> | 1996-07-30 19:00:12 +0000 |
| commit | f0850246bbf0c3a241574b8fe27f1f8641871381 (patch) | |
| tree | 8ae09bed7d1a97aebf3cc5dd147ea212f47dbed1 /usr.bin/time | |
| parent | edd84a267a1f58d8ec2c59b0da1b6ed629e2c328 (diff) | |
Notes
Diffstat (limited to 'usr.bin/time')
| -rw-r--r-- | usr.bin/time/time.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c index ebb4a4fff24e..e911d8c649d8 100644 --- a/usr.bin/time/time.c +++ b/usr.bin/time/time.c @@ -45,8 +45,13 @@ static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 6/6/93"; #include <sys/time.h> #include <sys/resource.h> #include <sys/signal.h> +#include <sys/sysctl.h> + +#include <err.h> #include <stdio.h> +static int getstathz __P((void)); + main(argc, argv) int argc; char **argv; @@ -102,7 +107,7 @@ main(argc, argv) fprintf(stderr, "%9ld.%02ld sys\n", ru.ru_stime.tv_sec, ru.ru_stime.tv_usec/10000); if (lflag) { - int hz = 100; /* XXX */ + int hz = getstathz(); u_long ticks; ticks = hz * (ru.ru_utime.tv_sec + ru.ru_stime.tv_sec) + @@ -146,3 +151,21 @@ main(argc, argv) } exit (status>>8); } + +/* + * Return the frequency of the kernel's statistics clock. + */ +static int +getstathz() +{ + struct clockinfo clockrate; + int mib[2]; + size_t size; + + mib[0] = CTL_KERN; + mib[1] = KERN_CLOCKRATE; + size = sizeof clockrate; + if (sysctl(mib, 2, &clockrate, &size, NULL, 0) == -1) + err(1, "sysctl kern.clockrate"); + return clockrate.stathz; +} |
