@@ -222,19 +222,36 @@ void TestMultiThreadPrediction(
222
222
// The inputs of each thread are all the same.
223
223
std::vector<PaddleTensor> outputs_tid;
224
224
auto &predictor = predictors[tid];
225
- LOG (INFO) << " running thread " << tid;
226
- Timer timer;
227
- timer.tic ();
228
- for (int i = 0 ; i < num_times; i++) {
229
- for (const auto &input : inputs) {
230
- ASSERT_TRUE (predictor->Run (input, &outputs_tid));
225
+
226
+ // warmup run
227
+ LOG (INFO) << " Running thread " << tid << " , warm up run..." ;
228
+ {
229
+ Timer warmup_timer;
230
+ warmup_timer.tic ();
231
+ predictor->Run (inputs[0 ], outputs, batch_size);
232
+ PrintTime (batch_size, 1 , num_threads, tid, warmup_timer.toc (), 1 );
233
+ #if !defined(_WIN32)
234
+ if (FLAGS_profile) {
235
+ paddle::platform::ResetProfiler ();
231
236
}
237
+ #endif
232
238
}
233
239
234
- auto time = timer.toc ();
235
- total_time += time;
236
- PrintTime (batch_size, num_times, num_threads, tid, time / num_times,
237
- inputs.size ());
240
+ LOG (INFO) << " Thread " << tid << " run " << num_times << " times..." ;
241
+ {
242
+ Timer timer;
243
+ timer.tic ();
244
+ for (int i = 0 ; i < num_times; i++) {
245
+ for (const auto &input : inputs) {
246
+ ASSERT_TRUE (predictor->Run (input, &outputs_tid));
247
+ }
248
+ }
249
+
250
+ auto time = timer.toc ();
251
+ total_time += time;
252
+ PrintTime (batch_size, num_times, num_threads, tid, time / num_times,
253
+ inputs.size ());
254
+ }
238
255
});
239
256
}
240
257
for (int i = 0 ; i < num_threads; ++i) {
0 commit comments