MCPcopy Create free account
hub / github.com/davisking/dlib / perform_test

Method perform_test

dlib/test/thread_pool.cpp:84–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82 {}
83
84 void perform_test (
85 )
86 {
87 add_functor f;
88 for (int num_threads= 0; num_threads < 4; ++num_threads)
89 {
90 dlib::future<int> a, b, c, res, d;
91 thread_pool tp(num_threads);
92 print_spinner();
93
94 dlib::future<some_struct> obj;
95
96
97 for (int i = 0; i < 4; ++i)
98 {
99 a = 1;
100 b = 2;
101 c = 3;
102 res = 4;
103
104
105 DLIB_TEST(a==a);
106 DLIB_TEST(a!=b);
107 DLIB_TEST(a==1);
108
109 tp.add_task(gset_to_zero, a);
110 tp.add_task(gset_to_zero, b);
111 tp.add_task(*this, &thread_pool_tester::set_to_zero, c);
112 tp.add_task(gset_to_zero, res);
113 DLIB_TEST(a == 0);
114 DLIB_TEST(b == 0);
115 DLIB_TEST(c == 0);
116 DLIB_TEST(res == 0);
117
118
119 tp.add_task(gincrement, a);
120 tp.add_task(*this, &thread_pool_tester::increment, b);
121 tp.add_task(*this, &thread_pool_tester::increment, c);
122 tp.add_task(gincrement, res);
123
124 DLIB_TEST(a == 1);
125 DLIB_TEST(b == 1);
126 DLIB_TEST(c == 1);
127 DLIB_TEST(res == 1);
128
129 tp.add_task(&gincrement, a);
130 tp.add_task(*this, &thread_pool_tester::increment, b);
131 tp.add_task(*this, &thread_pool_tester::increment, c);
132 tp.add_task(&gincrement, res);
133 tp.add_task(gincrement, a);
134 tp.add_task(*this, &thread_pool_tester::increment, b);
135 tp.add_task(*this, &thread_pool_tester::increment, c);
136 tp.add_task(gincrement, res);
137
138 DLIB_TEST(a == 3);
139 DLIB_TEST(b == 3);
140 DLIB_TEST(c == 3);
141 DLIB_TEST(res == 3);

Callers

nothing calls this directly

Calls 8

print_spinnerFunction · 0.85
add_functorClass · 0.85
errorClass · 0.85
wait_for_taskMethod · 0.80
wait_for_all_tasksMethod · 0.80
add_task_by_valueMethod · 0.80
add_taskMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected