Reduce cpp unittest time cost (#8409)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
pull/8414/head
groot 2021-09-23 17:55:54 +08:00 committed by GitHub
parent 10c07a3041
commit af1bdaf202
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 157 deletions

View File

@ -27,6 +27,10 @@ using namespace milvus;
using namespace milvus::query;
using namespace milvus::segcore;
namespace {
const int64_t ROW_COUNT = 100 * 1000;
}
TEST(Query, ShowExecutor) {
using namespace milvus::query;
using namespace milvus::segcore;
@ -161,7 +165,7 @@ TEST(Query, ExecWithPredicateLoader) {
]
}
})";
int64_t N = 1000 * 1000;
int64_t N = ROW_COUNT;
auto dataset = DataGen(schema, N);
auto segment = CreateGrowingSegment(schema);
segment->PreInsert(N);
@ -183,41 +187,11 @@ TEST(Query, ExecWithPredicateLoader) {
auto ref = json::parse(R"(
[
[
[
"982->0.000000",
"25315->4.741588",
"57893->4.758279",
"551029->5.078479",
"455002->5.134716"
],
[
"528353->8.740297",
"659305->8.802286",
"935763->9.422906",
"794649->9.436665",
"192031->9.832053"
],
[
"980439->3.342777",
"433044->3.424016",
"797884->3.663446",
"697705->3.944479",
"186546->4.404788"
],
[
"642941->3.753775",
"967504->3.885163",
"764517->4.364819",
"332938->4.418214",
"232724->4.574215"
],
[
"351788->4.453843",
"410227->4.699380",
"501497->4.805948",
"715061->5.166959",
"414882->5.179897"
]
["982->0.000000", "25315->4.741588", "57893->4.758279", "1499->6.065844", "48201->6.075444"],
["41772->10.110812", "80693->11.712179", "74859->11.789503", "79777->11.842009", "31878->12.308037"],
["65551->4.453535", "21617->5.143645", "50037->5.266983", "72204->5.331940", "96905->5.478549"],
["59219->5.458013", "21995->6.077806", "61367->7.028524", "44657->7.030965", "66957->7.174046"],
["66353->5.695784", "41087->5.916901", "97780->6.810793", "99239->7.561522", "86527->7.750667"]
]
])");
std::cout << json.dump(2);
@ -307,7 +281,7 @@ TEST(Query, ExecWithPredicate) {
]
}
})";
int64_t N = 1000 * 1000;
int64_t N = ROW_COUNT;
auto dataset = DataGen(schema, N);
auto segment = CreateGrowingSegment(schema);
segment->PreInsert(N);
@ -325,43 +299,13 @@ TEST(Query, ExecWithPredicate) {
Json json = SearchResultToJson(sr);
auto ref = json::parse(R"(
[
[
[
"982->0.000000",
"25315->4.741588",
"57893->4.758279",
"551029->5.078479",
"455002->5.134716"
],
[
"528353->8.740297",
"659305->8.802286",
"935763->9.422906",
"794649->9.436665",
"192031->9.832053"
],
[
"980439->3.342777",
"433044->3.424016",
"797884->3.663446",
"697705->3.944479",
"186546->4.404788"
],
[
"642941->3.753775",
"967504->3.885163",
"764517->4.364819",
"332938->4.418214",
"232724->4.574215"
],
[
"351788->4.453843",
"410227->4.699380",
"501497->4.805948",
"715061->5.166959",
"414882->5.179897"
]
]
[
["982->0.000000", "25315->4.741588", "57893->4.758279", "1499->6.065844", "48201->6.075444"],
["41772->10.110812", "80693->11.712179", "74859->11.789503", "79777->11.842009", "31878->12.308037"],
["65551->4.453535", "21617->5.143645", "50037->5.266983", "72204->5.331940", "96905->5.478549"],
["59219->5.458013", "21995->6.077806", "61367->7.028524", "44657->7.030965", "66957->7.174046"],
["66353->5.695784", "41087->5.916901", "97780->6.810793", "99239->7.561522", "86527->7.750667"]
]
])");
std::cout << json.dump(2);
ASSERT_EQ(json.dump(2), ref.dump(2));
@ -398,7 +342,7 @@ TEST(Query, ExecTerm) {
]
}
})";
int64_t N = 1000 * 1000;
int64_t N = ROW_COUNT;
auto dataset = DataGen(schema, N);
auto segment = CreateGrowingSegment(schema);
segment->PreInsert(N);
@ -444,7 +388,7 @@ TEST(Query, ExecEmpty) {
]
}
})";
int64_t N = 1000 * 1000;
int64_t N = ROW_COUNT;
auto segment = CreateGrowingSegment(schema);
auto plan = CreatePlan(*schema, dsl);
auto num_queries = 5;
@ -489,7 +433,7 @@ TEST(Query, ExecWithoutPredicateFlat) {
}
})";
auto plan = CreatePlan(*schema, dsl);
int64_t N = 1000 * 1000;
int64_t N = ROW_COUNT;
auto dataset = DataGen(schema, N);
auto segment = CreateGrowingSegment(schema);
segment->PreInsert(N);
@ -533,7 +477,7 @@ TEST(Query, ExecWithoutPredicate) {
}
})";
auto plan = CreatePlan(*schema, dsl);
int64_t N = 1000 * 1000;
int64_t N = ROW_COUNT;
auto dataset = DataGen(schema, N);
auto segment = CreateGrowingSegment(schema);
segment->PreInsert(N);
@ -551,45 +495,14 @@ TEST(Query, ExecWithoutPredicate) {
auto json = SearchResultToJson(sr);
auto ref = json::parse(R"(
[
[
[
"982->0.000000",
"25315->4.741588",
"57893->4.758279",
"694663->4.980466",
"551029->5.078479"
],
[
"559507->7.956653",
"871836->8.694542",
"528353->8.740297",
"659305->8.802286",
"516137->8.935913"
],
[
"980439->3.342777",
"433044->3.424016",
"527556->3.487235",
"797884->3.663446",
"814805->3.782786"
],
[
"642941->3.753775",
"967504->3.885163",
"177960->4.339530",
"764517->4.364819",
"841079->4.403300"
],
[
"688614->4.259011",
"351788->4.453843",
"452698->4.473838",
"410227->4.699380",
"501497->4.805948"
]
]
]
)");
[
["982->0.000000", "25315->4.741588", "57893->4.758279", "1499->6.065844", "48201->6.075444"],
["41772->10.110812", "80693->11.712179", "74859->11.789503", "79777->11.842009", "31878->12.308037"],
["65551->4.453535", "21617->5.143645", "50037->5.266983", "98268->5.320526", "72204->5.331940"],
["33572->5.431973", "59219->5.458013", "21995->6.077806", "17913->6.830949", "86628->6.834784"],
["66353->5.695784", "41087->5.916901", "24554->6.195437", "68019->6.653711", "97780->6.810793"]
]
])");
std::cout << json.dump(2);
ASSERT_EQ(json.dump(2), ref.dump(2));
}
@ -804,7 +717,7 @@ TEST(Query, ExecWithPredicateBinary) {
]
}
})";
int64_t N = 1000 * 1000;
int64_t N = ROW_COUNT;
auto dataset = DataGen(schema, N);
auto segment = CreateGrowingSegment(schema);
segment->PreInsert(N);

View File

@ -217,7 +217,7 @@ TEST(Sealed, with_predicate) {
TEST(Sealed, LoadFieldData) {
auto dim = 16;
auto topK = 5;
auto N = 1000 * 1000;
auto N = ROW_COUNT;
auto metric_type = MetricType::METRIC_L2;
auto schema = std::make_shared<Schema>();
auto fakevec_id = schema->AddDebugField("fakevec", DataType::VECTOR_FLOAT, dim, metric_type);
@ -304,43 +304,13 @@ TEST(Sealed, LoadFieldData) {
ASSERT_ANY_THROW(segment->Search(plan.get(), *ph_group, time));
auto std_json = Json::parse(R"(
[
[
[
"982->0.000000",
"25315->4.741588",
"551029->5.078479",
"455002->5.134716",
"504754->5.329021"
],
[
"287136->8.409121",
"528353->8.740297",
"935763->9.422906",
"794649->9.436665",
"192031->9.832053"
],
[
"59251->2.542610",
"433044->3.424016",
"797884->3.663446",
"430441->3.692723",
"697705->3.944479"
],
[
"611544->3.463480",
"642941->3.753775",
"967504->3.885163",
"232724->4.574215",
"507245->5.040902"
],
[
"351788->4.453843",
"410227->4.699380",
"501497->4.805948",
"715061->5.166959",
"414882->5.179897"
]
]
[
["982->0.000000", "25315->4.741588", "57893->4.758279", "48201->6.075444", "53853->6.223233"],
["41772->10.110812", "74859->11.789503", "79777->11.842009", "3785->11.982730", "35888->12.193403"],
["59251->2.542610", "65551->4.453535", "72204->5.331940", "96905->5.478549", "87833->5.765219"],
["59219->5.458013", "21995->6.077806", "97922->6.763784", "25710->7.158085", "14048->7.294020"],
["66353->5.695784", "30664->5.880683", "41087->5.916901", "10393->6.632869", "90215->7.201704"]
]
])");
ASSERT_EQ(std_json.dump(-2), json.dump(-2));
}

View File

@ -56,7 +56,7 @@ TEST(SegmentCoreTest, NormalDistributionTest) {
auto schema = std::make_shared<Schema>();
schema->AddDebugField("fakevec", DataType::VECTOR_FLOAT, 16, MetricType::METRIC_L2);
schema->AddDebugField("age", DataType::INT32);
int N = 1000 * 1000;
int N = 100 * 1000;
auto [raw_data, timestamps, uids] = generate_data(N);
auto segment = CreateGrowingSegment(schema);
segment->PreInsert(N);