Changeset 2172
- Timestamp:
- 05/07/07 04:10:37 (5 years ago)
- Files:
-
- trunk/tango/util/time/StopWatch.d (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tango/util/time/StopWatch.d
r2167 r2172 65 65 public struct StopWatch 66 66 { 67 private Intervalstarted;67 private ulong started; 68 68 private static Interval multiplier = 1.0 / 1_000_000.0; 69 70 version (Win32)71 private static ulong timerStart;72 69 73 70 /*********************************************************************** … … 90 87 Interval stop () 91 88 { 92 return timer - started;89 return multiplier * (timer - started); 93 90 } 94 91 … … 105 102 ulong freq; 106 103 107 if (! QueryPerformanceFrequency (&freq)) 108 throw new Exception ("high-resolution timer is not available"); 109 110 QueryPerformanceCounter (&timerStart); 104 QueryPerformanceFrequency (&freq); 111 105 multiplier = 1.0 / freq; 112 106 } … … 119 113 ***********************************************************************/ 120 114 121 private static Intervaltimer ()115 private static ulong timer () 122 116 { 123 117 version (Posix) … … 127 121 throw new Exception ("Timer :: linux timer is not available"); 128 122 129 return (cast( Interval) tv.tv_sec) + tv.tv_usec * multiplier;123 return (cast(ulong) tv.tv_sec * 1_000_000) + tv.tv_usec; 130 124 } 131 125 … … 134 128 ulong now; 135 129 136 QueryPerformanceCounter (&now); 137 return (now - timerStart) * multiplier; 130 if (! QueryPerformanceCounter (&now)) 131 throw new Exception ("high-resolution timer is not available"); 132 133 return now; 138 134 } 139 135 } … … 154 150 t.start; 155 151 156 for (int i=0; i < 10 _000_000; ++i)152 for (int i=0; i < 100_000_000; ++i) 157 153 {} 158 154 Stdout.format ("{:f9}", t.stop).newline;












