--- a/AbstractOperatingSystem.st Fri Dec 23 13:41:34 2011 +0000
+++ b/AbstractOperatingSystem.st Fri Jan 06 08:53:28 2012 +0000
@@ -5414,6 +5414,50 @@
aBlock value:hours value:minutes value:seconds value:millis
!
+getCPUCycleCount
+ "get a CPU specific cycle counter value.
+ Can be used for exact timing & performance measurements.
+ Notice, that the # of cycles has to be multiplied by the cycle time (1/cpu-frequency).
+
+ For x86:
+ the CPU cycle count register value is returned (RDTSC instruction).
+ Fails if RDTSC instruction is not supported (which is unlikely, nowadays).
+ For others:
+ currently fails"
+
+%{ /* NOCONTEXT */
+ unsigned int low, high;
+
+#ifdef i386
+ // use RDTSC instruction (retrieves 64bit cycle count; hi in EDX, lo in EAX)
+
+# if defined(__BORLANDC__)
+ _asm { push edx };
+ __emit__(0x0F,0x31); /* RDTSC instruction */
+ _asm { mov low,eax };
+ _asm { mov high,edx };
+ _asm { pop edx };
+# elif defined(_MSC_VER)
+ _asm { push edx };
+ _asm { _emit 0fh }; _asm { _emit 031h };
+ _asm { mov low,eax };
+ _asm { mov high,edx };
+ _asm { pop edx };
+# elif defined(__MINGW_H) || defined(__GNUC__)
+ asm volatile("rdtsc" : "=a"(low), "=d"(high));
+# else
+ goto unsupported;
+# endif
+#endif /* i386 */
+
+ RETURN ( __MKLARGEINT64(1, low, high) );
+unsupported: ;
+%}.
+ self primitiveFailed:'no CPU cycle register on this architecture'
+
+ "Created: / 05-01-2012 / 13:23:31 / cg"
+!
+
getMicrosecondTime
"This returns the microsecond timers value - if available.
On some machines, times with this precision may not be available,
@@ -7058,16 +7102,17 @@
!AbstractOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.215 2011/10/27 16:31:24 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.216 2012/01/05 13:08:45 cg Exp $'
!
version_CVS
- ^ 'Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.215 2011/10/27 16:31:24 stefan Exp '
+ ^ 'Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.216 2012/01/05 13:08:45 cg Exp '
!
version_SVN
- ^ '$Id: AbstractOperatingSystem.st 10729 2011-10-31 22:19:21Z vranyj1 $'
+ ^ '$Id: AbstractOperatingSystem.st 10754 2012-01-06 08:53:28Z vranyj1 $'
! !
AbstractOperatingSystem initialize!
+