You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_lar_fast_run_options.cpp 1.7 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include <gtest/gtest.h>
  2. #include <string.h>
  3. #include <memory>
  4. #include "./test_common.h"
  5. #include "test_options.h"
  6. using namespace lar;
  7. DECLARE_bool(lite);
  8. DECLARE_int32(iter);
  9. DECLARE_bool(fast_run);
  10. namespace {
  11. BOOL_OPTION_WRAP(fast_run);
  12. BOOL_OPTION_WRAP(lite);
  13. INT32_OPTION_WRAP(iter, 10);
  14. } // anonymous namespace
  15. TEST(TestLarFastRun, FAST_RUN) {
  16. double heristic_time = 0, fast_run_time = 0;
  17. lite::Timer timer("profile");
  18. {
  19. std::string model_path = "./shufflenet.mge";
  20. timer.reset_start();
  21. TEST_INT32_OPTION(iter, 1);
  22. heristic_time = timer.get_used_time();
  23. }
  24. {
  25. std::string model_path = "./shufflenet.mge";
  26. timer.reset_start();
  27. DEFINE_INT32_WRAP(iter, 1);
  28. TEST_BOOL_OPTION(fast_run);
  29. fast_run_time = timer.get_used_time();
  30. }
  31. //! profile time is longer than excute time
  32. ASSERT_LT(heristic_time, fast_run_time);
  33. }
  34. TEST(TestLarFastRun, FAST_RUN_LITE) {
  35. double heristic_time = 0, fast_run_time = 0;
  36. lite::Timer timer("profile");
  37. //! clear profile cache
  38. auto profile_cache = mgb::PersistentCache::inst().get_cache();
  39. DEFINE_BOOL_WRAP(lite);
  40. {
  41. std::string model_path = "./shufflenet.mge";
  42. timer.reset_start();
  43. TEST_INT32_OPTION(iter, 1);
  44. heristic_time = timer.get_used_time();
  45. }
  46. {
  47. std::string model_path = "./shufflenet.mge";
  48. timer.reset_start();
  49. DEFINE_INT32_WRAP(iter, 1);
  50. TEST_BOOL_OPTION(fast_run);
  51. fast_run_time = timer.get_used_time();
  52. }
  53. //! profile time is longer than excute time
  54. ASSERT_LT(heristic_time, fast_run_time);
  55. }