1 | /* Copyright 1996 Michael Messollen. All rights reserved. */ |
---|
2 | //////////////////////////////////////////////////////////// |
---|
3 | // emacs edit mode for this file is -*- C++ -*- |
---|
4 | // static char * rcsid = "$Id: timing.h,v 1.4 2006-05-16 14:46:50 Singular Exp $"; |
---|
5 | //////////////////////////////////////////////////////////// |
---|
6 | // It is possible to include this file multiple times for different |
---|
7 | // settings of TIMING (but now this isn't used) |
---|
8 | |
---|
9 | #undef TIMING_START |
---|
10 | #undef TIMING_END |
---|
11 | #undef TIMING_DEFINE_PRINT |
---|
12 | #undef TIMING_DEFINE_PRINTPROTO |
---|
13 | #undef TIMING_PRINT |
---|
14 | |
---|
15 | #ifdef TIMING |
---|
16 | #include <time.h> |
---|
17 | #include <sys/times.h> |
---|
18 | #ifdef HAVE_IOSTREAM |
---|
19 | #include <iostream> |
---|
20 | #define OSTREAM std::ostream |
---|
21 | #define ISTREAM std::istream |
---|
22 | #elif defined(HAVE_IOSTREAM_H) |
---|
23 | #include <iostream.h> |
---|
24 | #define OSTREAM ostream |
---|
25 | #define ISTREAM istream |
---|
26 | #endif |
---|
27 | #define TIMING_START(t) { struct tms timing_ ## t ## _start, timing_ ## t ## _end; \ |
---|
28 | times( &timing_ ## t ## _start ); |
---|
29 | #define TIMING_END(t) times( &timing_ ## t ## _end ); \ |
---|
30 | timing_ ## t ## _time += timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime; } |
---|
31 | #define TIMING_DEFINE_PRINT(t) long timing_ ## t ## _time; \ |
---|
32 | void timing_print_ ## t ( char * msg ) { CERR.setf( ios::fixed, ios::floatfield); CERR.precision(2); \ |
---|
33 | CERR << msg << float(timing_ ## t ## _time) / 60 << " sec" << "\n"; } |
---|
34 | #define TIMING_PRINT(t,msg) timing_print_ ## t ( msg ); |
---|
35 | #define TIMING_DEFINE_PRINTPROTO(t) void timing_print_ ## t ( char * ); |
---|
36 | #else |
---|
37 | #define TIMING_START(t) |
---|
38 | #define TIMING_END(t) |
---|
39 | #define TIMING_DEFINE_PRINT(t) |
---|
40 | #define TIMING_PRINT(t,msg) |
---|
41 | #define TIMING_DEFINE_PRINTPROTO(t) |
---|
42 | #endif /* TIMING */ |
---|
43 | |
---|
44 | /* |
---|
45 | $Log: not supported by cvs2svn $ |
---|
46 | Revision 1.3 1997/09/12 07:19:59 Singular |
---|
47 | * hannes/michael: libfac-0.3.0 |
---|
48 | |
---|
49 | Revision 1.2 1997/04/25 22:13:56 michael |
---|
50 | Version for libfac-0.2.1 |
---|
51 | |
---|
52 | Revision 1.1 1996/01/17 06:22:05 michael |
---|
53 | Initial revision |
---|
54 | |
---|
55 | */ |
---|