Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

time.c

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------- 00002 @COPYRIGHT : 00003 Copyright 1993,1994,1995 David MacDonald, 00004 McConnell Brain Imaging Centre, 00005 Montreal Neurological Institute, McGill University. 00006 Permission to use, copy, modify, and distribute this 00007 software and its documentation for any purpose and without 00008 fee is hereby granted, provided that the above copyright 00009 notice appear in all copies. The author and McGill University 00010 make no representations about the suitability of this 00011 software for any purpose. It is provided "as is" without 00012 express or implied warranty. 00013 ---------------------------------------------------------------------------- */ 00014 00015 #include <volume_io/internal_volume_io.h> 00016 #include <bicpl.h> 00017 00018 #ifndef lint 00019 static char rcsid[] = "$Header: /software/source//libraries/bicpl/Prog_utils/time.c,v 1.7 2000/02/05 21:27:13 stever Exp $"; 00020 #endif 00021 00022 private Real cpu_start_time; 00023 private Real real_start_time; 00024 00025 /* ----------------------------- MNI Header ----------------------------------- 00026 @NAME : start_timing 00027 @INPUT : 00028 @OUTPUT : 00029 @RETURNS : 00030 @DESCRIPTION: Starts timing a subset of a process. 00031 @METHOD : 00032 @GLOBALS : 00033 @CALLS : 00034 @CREATED : 1993 David MacDonald 00035 @MODIFIED : 00036 ---------------------------------------------------------------------------- */ 00037 00038 public void start_timing( void ) 00039 { 00040 cpu_start_time = current_cpu_seconds(); 00041 real_start_time = current_realtime_seconds(); 00042 } 00043 00044 /* ----------------------------- MNI Header ----------------------------------- 00045 @NAME : end_timing 00046 @INPUT : title 00047 n - number of iterations of job that were performed. 00048 @OUTPUT : 00049 @RETURNS : 00050 @DESCRIPTION: Computes the cpu and real time since the start time, 00051 prints this out divided by the number of iterations performed. 00052 @METHOD : 00053 @GLOBALS : 00054 @CALLS : 00055 @CREATED : 1993 David MacDonald 00056 @MODIFIED : 00057 ---------------------------------------------------------------------------- */ 00058 00059 public void end_timing( 00060 STRING title, 00061 int n ) 00062 { 00063 Real per_unit_real_time, per_unit_cpu_time; 00064 Real cpu_time, real_time; 00065 00066 if( n < 1 ) 00067 n = 1; 00068 00069 cpu_time = current_cpu_seconds() - cpu_start_time; 00070 real_time = current_realtime_seconds() - real_start_time; 00071 00072 per_unit_cpu_time = cpu_time / (Real) n; 00073 per_unit_real_time = real_time / (Real) n; 00074 00075 if( title != NULL ) 00076 print( "%s: ", title ); 00077 print( "per cycle: " ); 00078 print_time( "Cpu: %g %s\t", per_unit_cpu_time ); 00079 print_time( "Real: %g %s", per_unit_real_time ); 00080 00081 if( cpu_time > 0.0 && real_time > 0.0 ) 00082 print( " c/s: %g %g\n", (Real) n / cpu_time, (Real) n / real_time ); 00083 }

Generated on Wed Jul 28 09:10:58 2004 for BICPL by doxygen 1.3.7