perf_allocation.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #include "perf_precomp.hpp"
  5. #include <array>
  6. using namespace perf;
  7. #define ALLOC_MAT_SIZES ::perf::szSmall24, ::perf::szSmall32, ::perf::szSmall64, \
  8. ::perf::sz5MP, ::perf::sz2K, ::perf::szSmall128, ::perf::szODD, ::perf::szQVGA, \
  9. ::perf::szVGA, ::perf::szSVGA, ::perf::sz720p, ::perf::sz1080p, ::perf::sz2160p, \
  10. ::perf::sz4320p, ::perf::sz3MP, ::perf::szXGA, ::perf::szSXGA, ::perf::szWQHD, \
  11. ::perf::sznHD, ::perf::szqHD
  12. namespace opencv_test
  13. {
  14. typedef perf::TestBaseWithParam<MatType> MatDepth_tb;
  15. PERF_TEST_P(MatDepth_tb, DISABLED_Allocation_Aligned,
  16. testing::Values(CV_8UC1, CV_16SC1, CV_8UC3, CV_8UC4))
  17. {
  18. const int matType = GetParam();
  19. const cv::Mat utility(1, 1, matType);
  20. const size_t elementBytes = utility.elemSize();
  21. const std::array<cv::Size, 20> sizes{ALLOC_MAT_SIZES};
  22. std::array<size_t, 20> bytes;
  23. for (size_t i = 0; i < sizes.size(); ++i)
  24. {
  25. bytes[i] = sizes[i].width * sizes[i].height * elementBytes;
  26. }
  27. declare.time(60)
  28. .iterations(100);
  29. TEST_CYCLE()
  30. {
  31. for (int i = 0; i < 100000; ++i)
  32. {
  33. fastFree(fastMalloc(bytes[i % sizes.size()]));
  34. }
  35. }
  36. SANITY_CHECK_NOTHING();
  37. }
  38. };