perf_io_base64.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include "perf_precomp.hpp"
  2. namespace opencv_test
  3. {
  4. using namespace perf;
  5. typedef tuple<cv::Size, MatType, String> Size_MatType_Str_t;
  6. typedef TestBaseWithParam<Size_MatType_Str_t> Size_Mat_StrType;
  7. #define MAT_SIZES ::perf::sz1080p/*, ::perf::sz4320p*/
  8. #define MAT_TYPES CV_8UC1, CV_32FC1
  9. #define FILE_EXTENSION String(".xml"), String(".yml"), String(".json")
  10. PERF_TEST_P(Size_Mat_StrType, DISABLED_fs_text,
  11. testing::Combine(testing::Values(MAT_SIZES),
  12. testing::Values(MAT_TYPES),
  13. testing::Values(FILE_EXTENSION))
  14. )
  15. {
  16. Size size = get<0>(GetParam());
  17. int type = get<1>(GetParam());
  18. String ext = get<2>(GetParam());
  19. Mat src(size.height, size.width, type);
  20. Mat dst = src.clone();
  21. declare.in(src, WARMUP_RNG).out(dst);
  22. cv::String file_name = cv::tempfile(ext.c_str());
  23. cv::String key = "test_mat";
  24. TEST_CYCLE_MULTIRUN(2)
  25. {
  26. {
  27. FileStorage fs(file_name, cv::FileStorage::WRITE);
  28. fs << key << src;
  29. fs.release();
  30. }
  31. {
  32. FileStorage fs(file_name, cv::FileStorage::READ);
  33. fs[key] >> dst;
  34. fs.release();
  35. }
  36. }
  37. remove(file_name.c_str());
  38. SANITY_CHECK_NOTHING();
  39. }
  40. PERF_TEST_P(Size_Mat_StrType, DISABLED_fs_base64,
  41. testing::Combine(testing::Values(MAT_SIZES),
  42. testing::Values(MAT_TYPES),
  43. testing::Values(FILE_EXTENSION))
  44. )
  45. {
  46. Size size = get<0>(GetParam());
  47. int type = get<1>(GetParam());
  48. String ext = get<2>(GetParam());
  49. Mat src(size.height, size.width, type);
  50. Mat dst = src.clone();
  51. cv::String file_name = cv::tempfile(ext.c_str());
  52. cv::String key = "test_mat";
  53. declare.in(src, WARMUP_RNG).out(dst);
  54. TEST_CYCLE_MULTIRUN(2)
  55. {
  56. {
  57. FileStorage fs(file_name, cv::FileStorage::WRITE_BASE64);
  58. fs << key << src;
  59. fs.release();
  60. }
  61. {
  62. FileStorage fs(file_name, cv::FileStorage::READ);
  63. fs[key] >> dst;
  64. fs.release();
  65. }
  66. }
  67. remove(file_name.c_str());
  68. SANITY_CHECK_NOTHING();
  69. }
  70. } // namespace