Enhance random generator of unittest

Signed-off-by: FluorineDog <guilin.gou@zilliz.com>
This commit is contained in:
FluorineDog 2020-09-25 17:09:53 +08:00 committed by yefu.chen
parent 6554b2cf16
commit 5d5a20dce2
2 changed files with 19 additions and 9 deletions

View File

@ -19,6 +19,7 @@
#include "grpc/ClientProxy.h"
#include "interface/ConnectionImpl.h"
#include "utils/TimeRecorder.h"
#include <random>
const int N = 200000;
const int DIM = 16;
@ -31,9 +32,14 @@ const milvus::FieldValue GetData() {
for (int i = 0; i < N; i++) {
int32_data.push_back(i);
}
std::default_random_engine eng(rand() % 20);
std::normal_distribution<float> dis(0, 1);
std::vector<milvus::VectorData> vector_data;
for (int i = 0; i < N; i++) {
std::vector<float> float_data(DIM, 10.25);
std::vector<float> float_data(DIM);
for(auto &x: float_data) {
x = dis(eng);
}
milvus::VectorData vectorData;
vectorData.float_data = float_data;
vector_data.push_back(vectorData);

View File

@ -17,6 +17,7 @@
#include "interface/ConnectionImpl.h"
#include "utils/TimeRecorder.h"
#include "utils/Utils.h"
#include <random>
const int TOP_K = 10;
@ -38,16 +39,19 @@ int main(int argc , char**argv) {
partition_list.emplace_back("partition-3");
milvus::VectorParam vectorParam;
milvus::VectorData vectorData;
std::vector<float> float_data;
for (int i = 0; i < 100; ++i) {
float_data.emplace_back(i);
}
vectorData.float_data = float_data;
std::vector<milvus::VectorData> vector_records;
std::default_random_engine eng(rand() % 20);
std::normal_distribution<float> dis(0, 1);
for (int j = 0; j < 10; ++j) {
milvus::VectorData vectorData;
std::vector<float> float_data;
for (int i = 0; i < 100; ++i) {
float_data.emplace_back(dis(eng));
}
vectorData.float_data = float_data;
vector_records.emplace_back(vectorData);
}