MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / TEST_F

Function TEST_F

src/codec/codec_bench_test.cc:62–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62TEST_F(CodecBenchmarkTest, ProjectTest) {
63 Schema schema;
64 for (uint32_t i = 0; i < 100; i++) {
65 common::ColumnDesc* col = schema.Add();
66 col->set_name("col" + std::to_string(i));
67 col->set_data_type(type::kBigInt);
68 }
69 common::ColumnDesc* col_last = schema.Add();
70 col_last->set_name("col_last");
71 col_last->set_data_type(type::kVarchar);
72 std::string hello = "hello";
73 RowBuilder rb(schema);
74 uint32_t total_size = rb.CalTotalLength(hello.size());
75 void* ptr = ::malloc(total_size);
76 rb.SetBuffer(reinterpret_cast<int8_t*>(ptr), total_size);
77 for (uint32_t i = 0; i < 100; i++) {
78 int64_t val = 100;
79 rb.AppendInt64(val);
80 }
81 rb.AppendString(hello.c_str(), hello.size());
82 ProjectList plist;
83 uint32_t* idx = plist.Add();
84 *idx = 100;
85 uint32_t* idx2 = plist.Add();
86 *idx2 = 99;
87
88 uint64_t consumed = ::baidu::common::timer::get_micros();
89 std::map<int32_t, std::shared_ptr<Schema>> vers_schema;
90 vers_schema.insert(std::make_pair(1, std::make_shared<Schema>(schema)));
91 for (int64_t i = 1; i < 100; i++) {
92 RowProject rp(vers_schema, plist);
93 rp.Init();
94 for (int32_t j = 0; j < 1000; j++) {
95 int8_t* data = NULL;
96 uint32_t size = 0;
97 rp.Project(reinterpret_cast<int8_t*>(ptr), total_size, &data,
98 &size);
99 free(reinterpret_cast<void*>(data));
100 }
101 }
102 consumed = ::baidu::common::timer::get_micros() - consumed;
103 std::cout << "project 1000 records avg consumed:" << consumed / 100 << "μs"
104 << std::endl;
105}
106
107TEST_F(CodecBenchmarkTest, Encode_ts_vs_none_ts) {
108 char* bd = new char[128];

Callers

nothing calls this directly

Calls 15

to_stringFunction · 0.85
RunHasTsFunction · 0.85
RunNoneTsFunction · 0.85
EncodeFunction · 0.85
CalTotalLengthMethod · 0.80
SetBufferMethod · 0.80
insertMethod · 0.80
ProjectMethod · 0.80
sizeMethod · 0.45
AppendInt64Method · 0.45
AppendStringMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected