File: perf_io_base64.cpp

package info (click to toggle)
opencv 4.10.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 282,092 kB
  • sloc: cpp: 1,178,079; xml: 682,621; python: 49,092; lisp: 31,150; java: 25,469; ansic: 11,039; javascript: 6,085; sh: 1,214; cs: 601; perl: 494; objc: 210; makefile: 173
file content (86 lines) | stat: -rw-r--r-- 2,283 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "perf_precomp.hpp"

namespace opencv_test
{
using namespace perf;

typedef tuple<cv::Size, MatType, String> Size_MatType_Str_t;
typedef TestBaseWithParam<Size_MatType_Str_t> Size_Mat_StrType;

#define MAT_SIZES      ::perf::sz1080p/*, ::perf::sz4320p*/
#define MAT_TYPES      CV_8UC1, CV_32FC1
#define FILE_EXTENSION String(".xml"), String(".yml"), String(".json")


PERF_TEST_P(Size_Mat_StrType, DISABLED_fs_text,
            testing::Combine(testing::Values(MAT_SIZES),
                             testing::Values(MAT_TYPES),
                             testing::Values(FILE_EXTENSION))
             )
{
    Size   size = get<0>(GetParam());
    int    type = get<1>(GetParam());
    String ext  = get<2>(GetParam());

    Mat src(size.height, size.width, type);
    Mat dst = src.clone();

    declare.in(src, WARMUP_RNG).out(dst);

    cv::String file_name = cv::tempfile(ext.c_str());
    cv::String key       = "test_mat";

    TEST_CYCLE_MULTIRUN(2)
    {
        {
            FileStorage fs(file_name, cv::FileStorage::WRITE);
            fs << key << src;
            fs.release();
        }
        {
            FileStorage fs(file_name, cv::FileStorage::READ);
            fs[key] >> dst;
            fs.release();
        }
    }

    remove(file_name.c_str());
    SANITY_CHECK_NOTHING();
}

PERF_TEST_P(Size_Mat_StrType, DISABLED_fs_base64,
            testing::Combine(testing::Values(MAT_SIZES),
                             testing::Values(MAT_TYPES),
                             testing::Values(FILE_EXTENSION))
             )
{
    Size   size = get<0>(GetParam());
    int    type = get<1>(GetParam());
    String ext  = get<2>(GetParam());

    Mat src(size.height, size.width, type);
    Mat dst = src.clone();

    cv::String file_name = cv::tempfile(ext.c_str());
    cv::String key       = "test_mat";

    declare.in(src, WARMUP_RNG).out(dst);
    TEST_CYCLE_MULTIRUN(2)
    {
        {
            FileStorage fs(file_name, cv::FileStorage::WRITE_BASE64);
            fs << key << src;
            fs.release();
        }
        {
            FileStorage fs(file_name, cv::FileStorage::READ);
            fs[key] >> dst;
            fs.release();
        }
    }

    remove(file_name.c_str());
    SANITY_CHECK_NOTHING();
}

} // namespace