summaryrefslogtreecommitdiff
path: root/tests/benchtest1.c
diff options
context:
space:
mode:
authorrpj <rpj>2004-10-01 07:17:09 +0000
committerrpj <rpj>2004-10-01 07:17:09 +0000
commitb0cf9efa6afeb8a7dbddf124dae173a2d633c801 (patch)
tree8f208f15bd63cf69ae9e2ceb2d523296db8bca76 /tests/benchtest1.c
parent531ca4db4794aab863a898b4d079ccd59b424b25 (diff)
Mutex speedups
Diffstat (limited to 'tests/benchtest1.c')
-rw-r--r--tests/benchtest1.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/benchtest1.c b/tests/benchtest1.c
index 1a553dc..ce45cf2 100644
--- a/tests/benchtest1.c
+++ b/tests/benchtest1.c
@@ -101,6 +101,7 @@ runTest (char * testNameString, int mType)
int
main (int argc, char *argv[])
{
+ int i = 0;
CRITICAL_SECTION cs;
old_mutex_t ox;
pthread_mutexattr_init(&ma);
@@ -127,6 +128,45 @@ main (int argc, char *argv[])
overHeadMilliSecs = durationMilliSecs;
+ TESTSTART
+ assert((dummy_call(&i), 1) == one);
+ assert((dummy_call(&i), 1) == one);
+ TESTSTOP
+
+ durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
+
+ printf( "%-45s %15ld %15.3f\n",
+ "Dummy call x 2",
+ durationMilliSecs,
+ (float) durationMilliSecs * 1E3 / ITERATIONS);
+
+
+ TESTSTART
+ assert((interlocked_inc_with_conditionals(&i), 1) == one);
+ assert((interlocked_dec_with_conditionals(&i), 1) == one);
+ TESTSTOP
+
+ durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
+
+ printf( "%-45s %15ld %15.3f\n",
+ "Dummy call -> Interlocked with cond x 2",
+ durationMilliSecs,
+ (float) durationMilliSecs * 1E3 / ITERATIONS);
+
+
+ TESTSTART
+ assert((InterlockedIncrement(&i), 1) == one);
+ assert((InterlockedDecrement(&i), 1) == one);
+ TESTSTOP
+
+ durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
+
+ printf( "%-45s %15ld %15.3f\n",
+ "InterlockedOp x 2",
+ durationMilliSecs,
+ (float) durationMilliSecs * 1E3 / ITERATIONS);
+
+
InitializeCriticalSection(&cs);
TESTSTART
@@ -139,7 +179,7 @@ main (int argc, char *argv[])
durationMilliSecs = GetDurationMilliSecs(currSysTimeStart, currSysTimeStop) - overHeadMilliSecs;
printf( "%-45s %15ld %15.3f\n",
- "Simple Critical Section",
+ "Simple Critical Section x 2",
durationMilliSecs,
(float) durationMilliSecs * 1E3 / ITERATIONS);