diff --git a/test/net/test_mobilenet+ssd.cpp b/test/net/test_mobilenet+ssd.cpp index 9b4e5f2d3a431001e138977b78994f5dfedbe0a3..ae6c40961ca96ea032b1822f17a663baedc8f661 100644 --- a/test/net/test_mobilenet+ssd.cpp +++ b/test/net/test_mobilenet+ssd.cpp @@ -32,10 +32,14 @@ int main() { std::vector dims{1, 3, 300, 300}; GetInput(g_hand, &input, dims); - auto time3 = time(); + // 预热一次 auto output = paddle_mobile.Predict(input, dims); + auto time3 = time(); + for (int i = 0; i < 10; ++i) { + auto output = paddle_mobile.Predict(input, dims); + } auto time4 = time(); - std::cout << "predict cost :" << time_diff(time3, time4) << "ms" + std::cout << "predict cost :" << time_diff(time3, time4) / 10 << "ms" << std::endl; } return 0; diff --git a/test/net/test_mobilenet.cpp b/test/net/test_mobilenet.cpp index 9fc7226fc12fa7a0c631c9920487c0bd56c90816..d7793f729866024e2560ad13ac5613172eecc4dd 100644 --- a/test/net/test_mobilenet.cpp +++ b/test/net/test_mobilenet.cpp @@ -26,19 +26,22 @@ int main() { std::vector input; std::vector dims{1, 3, 224, 224}; - GetInput(g_test_image_1x3x224x224, &input, dims); + GetInput(g_test_image_1x3x224x224_banana, &input, dims); + // 预热一次 + auto vec_result = paddle_mobile.Predict(input, dims); + std::vector::iterator biggest = + std::max_element(std::begin(vec_result), std::end(vec_result)); + std::cout << " Max element is " << *biggest << " at position " + << std::distance(std::begin(vec_result), biggest) << std::endl; + + auto time3 = time(); for (int i = 0; i < 10; ++i) { - auto time3 = time(); auto vec_result = paddle_mobile.Predict(input, dims); - auto time4 = time(); - std::vector::iterator biggest = - std::max_element(std::begin(vec_result), std::end(vec_result)); - std::cout << " Max element is " << *biggest << " at position " - << std::distance(std::begin(vec_result), biggest) << std::endl; - std::cout << "predict cost :" << time_diff(time3, time4) << "ms" - << std::endl; } + auto time4 = time(); + std::cout << "predict cost :" << time_diff(time3, time4) / 10 << "ms" + << std::endl; } return 0;