aboutsummaryrefslogtreecommitdiffhomepage
path: root/fish_tests.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-04-17 12:02:43 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-04-17 16:07:50 -0700
commit3d1a204c83c2657b1009a268c9b399edd97ea893 (patch)
tree73fafaefded816b32f474de998f2eb2c2849c210 /fish_tests.cpp
parent1ce30deec3ede38fba7fef2c35eafa4de700f333 (diff)
Simplify threading implementation. Removed iothread array. Threads now
run detached (no more pthread_join), and will not exit until they see that all requests have been dequeued.
Diffstat (limited to 'fish_tests.cpp')
-rw-r--r--fish_tests.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/fish_tests.cpp b/fish_tests.cpp
index dcc6814e..d66a319f 100644
--- a/fish_tests.cpp
+++ b/fish_tests.cpp
@@ -494,20 +494,26 @@ static void test_iothread(void)
{
say(L"Testing iothreads");
int *int_ptr = new int(0);
- int iterations = 1000;
+ int iterations = 5000000;
+ int max_achieved_thread_count = 0;
+ double start = timef();
for (int i=0; i < iterations; i++)
{
- iothread_perform(test_iothread_thread_call, (void (*)(int *, int))NULL, int_ptr);
+ int thread_count = iothread_perform(test_iothread_thread_call, (void (*)(int *, int))NULL, int_ptr);
+ max_achieved_thread_count = std::max(max_achieved_thread_count, thread_count);
}
// Now wait until we're done
iothread_drain_all();
+ double end = timef();
// Should have incremented it once per thread
if (*int_ptr != iterations)
{
say(L"Expected int to be %d, but instead it was %d", iterations, *int_ptr);
}
+
+ say(L" (%.02f msec, with max of %d threads)", (end - start) * 1000.0, max_achieved_thread_count);
delete int_ptr;
}