Milestone 4
This commit is contained in:
parent
691eb327d0
commit
420da2d468
6 changed files with 1039 additions and 24 deletions
|
|
@ -41,7 +41,7 @@ bool ParseUInt(const char* value, uint32_t* out) {
|
|||
|
||||
void PrintUsage() {
|
||||
std::cout << "warppipe_perf usage:\n"
|
||||
<< " --mode create-destroy|registry|links\n"
|
||||
<< " --mode create-destroy|registry|links|policy\n"
|
||||
<< " --type sink|source|both\n"
|
||||
<< " --count N (default 200, per-type when --type both)\n"
|
||||
<< " --events N (registry mode, default 100)\n"
|
||||
|
|
@ -94,7 +94,8 @@ bool ParseArgs(int argc, char* argv[], Options* options) {
|
|||
if (options->type != "sink" && options->type != "source" && options->type != "both") {
|
||||
return false;
|
||||
}
|
||||
if (options->mode != "create-destroy" && options->mode != "registry" && options->mode != "links") {
|
||||
if (options->mode != "create-destroy" && options->mode != "registry" &&
|
||||
options->mode != "links" && options->mode != "policy") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -347,6 +348,60 @@ int main(int argc, char* argv[]) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (options.mode == "policy") {
|
||||
auto sink = client.value->CreateVirtualSink(prefix + "-target-sink", node_options);
|
||||
if (!sink.ok()) {
|
||||
std::cerr << "create target sink failed: " << sink.status.message << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
warppipe::RouteRule rule;
|
||||
rule.match.application_name = "warppipe-perf";
|
||||
rule.target_node = prefix + "-target-sink";
|
||||
auto rule_result = client.value->AddRouteRule(rule);
|
||||
if (!rule_result.ok()) {
|
||||
std::cerr << "add rule failed: " << rule_result.status.message << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::vector<warppipe::NodeId> sources;
|
||||
sources.reserve(options.count);
|
||||
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
for (uint32_t i = 0; i < options.count; ++i) {
|
||||
std::string name = prefix + "-ephemeral-" + std::to_string(i);
|
||||
auto source = client.value->CreateVirtualSource(name, node_options);
|
||||
if (!source.ok()) {
|
||||
std::cerr << "create source failed at " << i << ": "
|
||||
<< source.status.message << "\n";
|
||||
break;
|
||||
}
|
||||
sources.push_back(source.value.node);
|
||||
}
|
||||
auto created = std::chrono::steady_clock::now();
|
||||
|
||||
for (const auto& node : sources) {
|
||||
client.value->RemoveNode(node);
|
||||
}
|
||||
auto destroyed = std::chrono::steady_clock::now();
|
||||
|
||||
client.value->RemoveRouteRule(rule_result.value);
|
||||
client.value->RemoveNode(sink.value.node);
|
||||
|
||||
const double create_ms = ToMillis(created - start);
|
||||
const double destroy_ms = ToMillis(destroyed - created);
|
||||
const double total_ms = ToMillis(destroyed - start);
|
||||
const double ops = static_cast<double>(sources.size());
|
||||
std::cout << "policy_sources=" << sources.size() << "\n"
|
||||
<< "policy_create_ms=" << std::fixed << std::setprecision(2) << create_ms << "\n"
|
||||
<< "policy_destroy_ms=" << destroy_ms << "\n"
|
||||
<< "policy_total_ms=" << total_ms << "\n";
|
||||
if (total_ms > 0.0) {
|
||||
std::cout << "policy_ops_per_sec=" << (ops / (total_ms / 1000.0)) << "\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrintUsage();
|
||||
return 2;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue