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.
This commit is contained in:
Tim-Philipp Müller 2018-01-11 18:39:50 +00:00
parent 5feff26624
commit db0c54c5c8

View file

@ -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;
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];
/* 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);