From db0c54c5c8299f751a6f1ac249ed792a50748c51 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 11 Jan 2018 18:39:50 +0000 Subject: [PATCH] tests: systemclock: scale stress test threads according to number of cpus Scale the number of threads used in the stress tests according to the number of cores/cpus. We want some contention, but we also don't want too much contention, as some operating systems are better at handling 100 threads running wild on a single core than others. --- tests/check/gst/gstsystemclock.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/check/gst/gstsystemclock.c b/tests/check/gst/gstsystemclock.c index a37bb15..59b3af1 100644 --- a/tests/check/gst/gstsystemclock.c +++ b/tests/check/gst/gstsystemclock.c @@ -827,10 +827,13 @@ unschedule_thread_func (gpointer data) GST_START_TEST (test_stress_cleanup_unschedule) { - WaitUnscheduleData data[50]; - gint i; + WaitUnscheduleData *data; + gint i, num; - for (i = 0; i < G_N_ELEMENTS (data); i++) { + num = g_get_num_processors () * 6; + data = g_newa (WaitUnscheduleData, num); + + for (i = 0; i < num; i++) { WaitUnscheduleData *d = &data[i]; /* Don't unschedule waits with positive offsets in order to trigger @@ -854,7 +857,7 @@ GST_START_TEST (test_stress_cleanup_unschedule) g_usleep (G_USEC_PER_SEC); /* Stop and free test data */ - for (i = 0; i < G_N_ELEMENTS (data); i++) { + for (i = 0; i < num; i++) { WaitUnscheduleData *d = &data[i]; d->running = FALSE; g_thread_join (d->thread_wait); @@ -868,10 +871,13 @@ GST_END_TEST; GST_START_TEST (test_stress_reschedule) { - WaitUnscheduleData data[50]; - gint i; + WaitUnscheduleData *data; + gint i, num; + + num = g_get_num_processors () * 6; + data = g_newa (WaitUnscheduleData, num); - for (i = 0; i < G_N_ELEMENTS (data); i++) { + for (i = 0; i < num; i++) { WaitUnscheduleData *d = &data[i]; /* Try to unschedule all waits */ @@ -893,7 +899,7 @@ GST_START_TEST (test_stress_reschedule) g_usleep (G_USEC_PER_SEC); /* Stop and free test data */ - for (i = 0; i < G_N_ELEMENTS (data); i++) { + for (i = 0; i < num; i++) { WaitUnscheduleData *d = &data[i]; d->running = FALSE; g_thread_join (d->thread_wait); -- 2.7.4