Add teps and pointwise lookup scenarios
Reviewers: mculinovic Reviewed By: mculinovic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1211
This commit is contained in:
parent
6236fbbcb4
commit
f1cdae0617
@ -19,12 +19,20 @@ BOOST_CLASS_EXPORT(stats::BatchStatsRes);
|
|||||||
|
|
||||||
class CardFraudClient : public TestClient {
|
class CardFraudClient : public TestClient {
|
||||||
public:
|
public:
|
||||||
CardFraudClient(int id, int num_pos, nlohmann::json config)
|
CardFraudClient(int id, int num_pos, int num_cards, int num_transactions,
|
||||||
: TestClient(), rg_(id), num_pos_(num_pos), config_(config) {}
|
nlohmann::json config)
|
||||||
|
: TestClient(),
|
||||||
|
rg_(id),
|
||||||
|
num_pos_(num_pos),
|
||||||
|
num_cards_(num_cards),
|
||||||
|
num_transactions_(num_transactions),
|
||||||
|
config_(config) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::mt19937 rg_;
|
std::mt19937 rg_;
|
||||||
int num_pos_;
|
int num_pos_;
|
||||||
|
int num_cards_;
|
||||||
|
int num_transactions_;
|
||||||
nlohmann::json config_;
|
nlohmann::json config_;
|
||||||
|
|
||||||
auto GetFraudulentTransactions() {
|
auto GetFraudulentTransactions() {
|
||||||
@ -53,6 +61,15 @@ class CardFraudClient : public TestClient {
|
|||||||
{{"id", id}});
|
{{"id", id}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto GetTransaction(int id) {
|
||||||
|
return Execute("MATCH (t:Transaction {id: $id}) RETURN (t)", {{"id", id}});
|
||||||
|
}
|
||||||
|
|
||||||
|
auto TepsQuery() {
|
||||||
|
auto result = Execute("MATCH (u)--(v) RETURN count(1)", {});
|
||||||
|
DCHECK(result.records[0][0].ValueInt() == num_transactions_ * 2);
|
||||||
|
}
|
||||||
|
|
||||||
auto CompromisePos(int id) {
|
auto CompromisePos(int id) {
|
||||||
return Execute(
|
return Execute(
|
||||||
"MATCH (p:Pos {id: $id}) "
|
"MATCH (p:Pos {id: $id}) "
|
||||||
@ -77,15 +94,21 @@ class CardFraudClient : public TestClient {
|
|||||||
CompromisePos(pos_id);
|
CompromisePos(pos_id);
|
||||||
GetFraudulentTransactions();
|
GetFraudulentTransactions();
|
||||||
ResolvePos(pos_id);
|
ResolvePos(pos_id);
|
||||||
|
} else if (config_["scenario"] == "teps") {
|
||||||
|
TepsQuery();
|
||||||
|
} else if (config_["scenario"] == "point_lookup") {
|
||||||
|
std::uniform_int_distribution<int> dist(0, num_transactions_ - 1);
|
||||||
|
int tx_id = dist(rg_);
|
||||||
|
GetTransaction(tx_id);
|
||||||
} else {
|
} else {
|
||||||
LOG(FATAL) << "Should not get here!";
|
LOG(FATAL) << "Should not get here!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int64_t NumPos(BoltClient &client) {
|
int64_t NumNodesWithLabel(BoltClient &client, std::string label) {
|
||||||
auto result = ExecuteNTimesTillSuccess(
|
std::string query = fmt::format("MATCH (u :{}) RETURN COUNT(u)", label);
|
||||||
client, "MATCH (n :Pos) RETURN COUNT(n) as cnt;", {}, MAX_RETRIES);
|
auto result = ExecuteNTimesTillSuccess(client, query, {}, MAX_RETRIES);
|
||||||
return result.records[0][0].ValueInt();
|
return result.records[0][0].ValueInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,16 +138,23 @@ int main(int argc, char **argv) {
|
|||||||
std::cin >> config;
|
std::cin >> config;
|
||||||
|
|
||||||
BoltClient client(FLAGS_address, FLAGS_port, FLAGS_username, FLAGS_password);
|
BoltClient client(FLAGS_address, FLAGS_port, FLAGS_username, FLAGS_password);
|
||||||
int num_pos = NumPos(client);
|
|
||||||
CreateIndex(client, "Card", "id");
|
|
||||||
CreateIndex(client, "Pos", "id");
|
|
||||||
CreateIndex(client, "Transaction", "fraud_reported");
|
|
||||||
|
|
||||||
|
int num_pos = NumNodesWithLabel(client, "Pos");
|
||||||
|
int num_cards = NumNodesWithLabel(client, "Card");
|
||||||
|
int num_transactions = NumNodesWithLabel(client, "Transaction");
|
||||||
|
|
||||||
|
CreateIndex(client, "Pos", "id");
|
||||||
|
CreateIndex(client, "Card", "id");
|
||||||
|
CreateIndex(client, "Transaction", "fraud_reported");
|
||||||
|
CreateIndex(client, "Transaction", "id");
|
||||||
LOG(INFO) << "Done building indexes.";
|
LOG(INFO) << "Done building indexes.";
|
||||||
|
|
||||||
|
client.Close();
|
||||||
|
|
||||||
std::vector<std::unique_ptr<TestClient>> clients;
|
std::vector<std::unique_ptr<TestClient>> clients;
|
||||||
for (int i = 0; i < FLAGS_num_workers; ++i) {
|
for (int i = 0; i < FLAGS_num_workers; ++i) {
|
||||||
clients.emplace_back(std::make_unique<CardFraudClient>(i, num_pos, config));
|
clients.emplace_back(std::make_unique<CardFraudClient>(
|
||||||
|
i, num_pos, num_cards, num_transactions, config));
|
||||||
}
|
}
|
||||||
|
|
||||||
RunMultithreadedTest(clients);
|
RunMultithreadedTest(clients);
|
||||||
|
@ -150,7 +150,7 @@ void RunMultithreadedTest(std::vector<std::unique_ptr<TestClient>> &clients) {
|
|||||||
auto it = aggregated_query_stats.insert({stat.first, DecodedValue(0.0)})
|
auto it = aggregated_query_stats.insert({stat.first, DecodedValue(0.0)})
|
||||||
.first;
|
.first;
|
||||||
it->second =
|
it->second =
|
||||||
(it->second.ValueDouble() * old_count + stat.second * new_count) /
|
(it->second.ValueDouble() * old_count + stat.second) /
|
||||||
(old_count + new_count);
|
(old_count + new_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"scenario": "point_lookup"
|
||||||
|
}
|
3
tests/macro_benchmark/groups/card_fraud/teps.run.json
Normal file
3
tests/macro_benchmark/groups/card_fraud/teps.run.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"scenario": "teps"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user