Commit | Line | Data |
---|---|---|
5e38caf1 KN |
1 | ;;;; Copyright (C) 2001 Free Software Foundation, Inc. |
2 | ;;;; | |
3 | ;;;; This program is free software; you can redistribute it and/or modify | |
4 | ;;;; it under the terms of the GNU General Public License as published by | |
5 | ;;;; the Free Software Foundation; either version 2, or (at your option) | |
6 | ;;;; any later version. | |
7 | ;;;; | |
8 | ;;;; This program is distributed in the hope that it will be useful, | |
9 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | ;;;; GNU General Public License for more details. | |
12 | ;;;; | |
13 | ;;;; You should have received a copy of the GNU General Public License | |
14 | ;;;; along with this software; see the file COPYING. If not, write to | |
15 | ;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |
16 | ;;;; Boston, MA 02111-1307 USA | |
17 | ;;;; | |
18 | \f | |
19 | ||
20 | (define-module (ice-9 time) | |
21 | :use-module (ice-9 format) | |
22 | :export (time)) | |
23 | ||
3b9e23a7 | 24 | (define (time-proc proc) |
5e38caf1 | 25 | (let* ((gc-start (gc-run-time)) |
3b9e23a7 KN |
26 | (tms-start (times)) |
27 | (result (proc)) | |
28 | (tms-end (times)) | |
29 | (gc-end (gc-run-time))) | |
5e38caf1 KN |
30 | (define (get proc start end) |
31 | (/ (- (proc end) (proc start)) internal-time-units-per-second)) | |
32 | (display "clock utime stime cutime cstime gctime\n") | |
33 | (format #t "~5,2F ~5,2F ~5,2F ~6,2F ~6,2F ~6,2F\n" | |
3b9e23a7 KN |
34 | (get tms:clock tms-start tms-end) |
35 | (get tms:utime tms-start tms-end) | |
36 | (get tms:stime tms-start tms-end) | |
37 | (get tms:cutime tms-start tms-end) | |
38 | (get tms:cstime tms-start tms-end) | |
39 | (get id gc-start gc-end)) | |
5e38caf1 | 40 | result)) |
3b9e23a7 KN |
41 | |
42 | (define-macro (time exp) | |
43 | `(,time-proc (lambda () ,exp))) |