Changeset 2103 for libswish3/trunk/src/libswish3/times.c
- Timestamp:
- 03/27/08 23:35:21 (10 months ago)
- Files:
-
- libswish3/trunk/src/libswish3/times.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libswish3/trunk/src/libswish3/times.c
r2101 r2103 36 36 37 37 double 38 swish_time_elapsed(void) 38 swish_time_elapsed( 39 void 40 ) 39 41 { 40 42 #ifdef HAVE_SYS_TIMEB_H 41 43 #include <sys/timeb.h> 42 44 43 struct timeb ftimebuf;45 struct timeb ftimebuf; 44 46 45 47 ftime(&ftimebuf); 46 return (double) ftimebuf.time + (double)ftimebuf.millitm / 1000.0;48 return (double)ftimebuf.time + (double)ftimebuf.millitm / 1000.0; 47 49 48 50 #else 49 51 50 return ((double)clock()) / CLOCKS_PER_SEC;52 return ((double)clock()) / CLOCKS_PER_SEC; 51 53 52 54 #endif … … 58 60 59 61 double 60 swish_time_elapsed(void) 62 swish_time_elapsed( 63 void 64 ) 61 65 { 62 struct timeval t;63 int i;66 struct timeval t; 67 int i; 64 68 65 69 i = gettimeofday(&t, NULL); … … 67 71 return 0; 68 72 69 return (double) (t.tv_sec + t.tv_usec / 1000000.0);73 return (double)(t.tv_sec + t.tv_usec / 1000000.0); 70 74 } 71 75 #endif … … 73 77 /* return CPU time used */ 74 78 double 75 swish_time_cpu(void) 79 swish_time_cpu( 80 void 81 ) 76 82 { 77 return (double) get_cpu_secs();83 return (double)get_cpu_secs(); 78 84 } 79 85 80 char * 81 swish_print_time(double time) 86 char * 87 swish_print_time( 88 double time 89 ) 82 90 { 83 int hh, mm, ss;84 int delta;85 char *str;91 int hh, mm, ss; 92 int delta; 93 char *str; 86 94 87 95 if (time < 0) 88 96 time = 0; 89 97 90 delta = (int) (time + 0.5);98 delta = (int)(time + 0.5); 91 99 ss = delta % 60; 92 100 delta /= 60; … … 100 108 else { 101 109 swish_xfree(str); 102 return (char *) swish_xstrdup((xmlChar *)"unknown time");110 return (char *)swish_xstrdup((xmlChar *)"unknown time"); 103 111 } 104 112 } 105 113 106 char * 107 swish_print_fine_time(double time) 114 char * 115 swish_print_fine_time( 116 double time 117 ) 108 118 { 109 char *str;119 char *str; 110 120 111 121 if (time >= 10) … … 118 128 else { 119 129 swish_xfree(str); 120 return (char *) swish_xstrdup((xmlChar *)"unknown fine time");130 return (char *)swish_xstrdup((xmlChar *)"unknown fine time"); 121 131 } 122 132
