maybe fix decreasing results from process-milliseconds

svn: r8226
This commit is contained in:
Matthew Flatt 2008-01-05 21:04:12 +00:00
parent 8f87430c49
commit 4b24262f96
3 changed files with 22 additions and 19 deletions

View File

@ -60,7 +60,7 @@ cases where IEEE provides no specification (e.g., @scheme[(angle
+inf.0+inf.0)]), the result corresponds to the limit approaching
infinity, or @scheme[+nan.0] if no such limit exists.
A @pidefterm{fixnum} is an exact integer whose two's complement
A @deftech{fixnum} is an exact integer whose two's complement
representation fit into 31 bits on a 32-bit platform or 63 bits on a
64-bit platform. Two fixnums that are @scheme[=] are also the same
according to @scheme[eq?]. Otherwise, the result of @scheme[eq?]

View File

@ -56,36 +56,35 @@ especially on Unix platforms; consult the system documentation
@defproc[(current-milliseconds) exact-integer?]{
Returns the current ``time'' in fixnum milliseconds (possibly
Returns the current ``time'' in @tech{fixnum} milliseconds (possibly
negative). This time is based on a platform-specific starting date or
on the machine's startup time. Since the result is a fixnum, the value
increases only over a limited (though reasonably long) time.}
on the machine's startup time. Since the result is a @tech{fixnum},
the value increases only over a limited (though reasonably long)
time.}
@defproc[(current-inexact-milliseconds) real?]{
Returns the current ``time'' in positive milliseconds, not necessarily
an integer. This time is based on a platform-specific starting date or
on the machine's startup time, but it never decreases (until the
machine is turned off).}
Like @scheme[current-milliseconds], but the result never decreases
(until the machine is turned off).}
@defproc[(current-process-milliseconds) exact-integer?]{
Returns the amount of processor time in fixnum milliseconds that has
been consumed by the Scheme process on the underlying operating
system. (Under @|AllUnix|, this includes both user and system time.)
The precision of the result is platform-specific, and since the result
is a fixnum, the value increases only over a limited (though
reasonably long) time.}
Returns the amount of processor time in @tech{fixnum} milliseconds
that has been consumed by the Scheme process on the underlying
operating system. (Under @|AllUnix|, this includes both user and
system time.) The precision of the result is platform-specific, and
since the result is a @tech{fixnum}, the value increases only over a
limited (though reasonably long) time.}
@defproc[(current-gc-milliseconds) exact-integer?]{
Returns the amount of processor time in fixnum milliseconds that has
been consumed by Scheme's garbage collection so far. This time is a
portion of the time reported by
@scheme[(current-process-milliseconds)].}
Returns the amount of processor time in @tech{fixnum} milliseconds
that has been consumed by Scheme's garbage collection so far. This
time is a portion of the time reported by
@scheme[(current-process-milliseconds)], and is similarly limited.}
@defproc[(time-apply [proc procedure?]

View File

@ -54,6 +54,7 @@
# include <sys/types.h>
# include <sys/time.h>
# include <sys/resource.h>
# include <errno.h>
# endif /* USE_GETRUSAGE */
# ifdef USE_SYSCALL_GETRUSAGE
# include <sys/syscall.h>
@ -7473,7 +7474,10 @@ long scheme_get_process_milliseconds(void)
struct rusage use;
long s, u;
getrusage(RUSAGE_SELF, &use);
do {
if (!getrusage(RUSAGE_SELF, &use))
break;
} while (errno == EINTR);
s = use.ru_utime.tv_sec + use.ru_stime.tv_sec;
u = use.ru_utime.tv_usec + use.ru_stime.tv_usec;