change flags type, name according to the comments.

change binary search stride from 1 to FLAGS_precision
pull/8313/head
Yuxuan Li 8 years ago
parent 77c18981c2
commit 69c61319df
  1. 37
      test/cpp/qps/qps_json_driver.cc
  2. 1
      test/cpp/qps/report.cc

@ -49,13 +49,13 @@ DEFINE_string(scenarios_file, "",
DEFINE_string(scenarios_json, "", DEFINE_string(scenarios_json, "",
"JSON string containing an array of Scenario objects"); "JSON string containing an array of Scenario objects");
DEFINE_bool(quit, false, "Quit the workers"); DEFINE_bool(quit, false, "Quit the workers");
DEFINE_bool( DEFINE_string(
search, false, search_param, "",
"Search for the offered_load value that achieves targeted cpu load"); "The parameter, whose value is to be searched for to achieve targeted cpu load");
DEFINE_double(initial_offered_load, 1000.0, DEFINE_double(initial_search_value, 1000.0,
"Set up for intial offered load to start the search"); "initial parameter value to start the search with (i.e. lower bound)");
DEFINE_double(targeted_cpu_load, 99.0, "Targeted cpu load"); DEFINE_double(targeted_cpu_load, 99.0, "Targeted cpu load (unit: %, range [0,100])");
DEFINE_double(precision, 500, "Final search result precision"); DEFINE_double(precision, 500, "Threshold for the search range, below which will end the search.");
namespace grpc { namespace grpc {
namespace testing { namespace testing {
@ -110,11 +110,11 @@ static double BinarySearch(Scenario* scenario, double targeted_cpu_load,
break; break;
} }
if (targeted_cpu_load < current_cpu_load) { if (targeted_cpu_load < current_cpu_load) {
high = mid - 1; high = mid - FLAGS_precision;
} else if (targeted_cpu_load > current_cpu_load) { } else if (targeted_cpu_load > current_cpu_load) {
low = mid + 1; low = mid + FLAGS_precision;
} else { } else {
high = mid - 1; high = mid - FLAGS_precision;
} }
} }
@ -186,15 +186,20 @@ static bool QpsDriver() {
GPR_ASSERT(scenarios.scenarios_size() > 0); GPR_ASSERT(scenarios.scenarios_size() > 0);
for (int i = 0; i < scenarios.scenarios_size(); i++) { for (int i = 0; i < scenarios.scenarios_size(); i++) {
if (!FLAGS_search) { if (FLAGS_search_param == "") {
const Scenario& scenario = scenarios.scenarios(i); const Scenario& scenario = scenarios.scenarios(i);
RunAndReport(scenario, &success); RunAndReport(scenario, &success);
} else { } else {
Scenario* scenario = scenarios.mutable_scenarios(i); if (FLAGS_search_param == "offered_load") {
double targeted_offered_load = Scenario* scenario = scenarios.mutable_scenarios(i);
SearchOfferedLoad(FLAGS_initial_offered_load, FLAGS_targeted_cpu_load, double targeted_offered_load =
scenario, &success); SearchOfferedLoad(FLAGS_initial_search_value, FLAGS_targeted_cpu_load,
gpr_log(GPR_INFO, "targeted_offered_load %f", targeted_offered_load); scenario, &success);
gpr_log(GPR_INFO, "targeted_offered_load %f", targeted_offered_load);
}
else {
gpr_log(GPR_ERROR, "Unimplemented search param");
}
} }
} }
return success; return success;

@ -76,6 +76,7 @@ void CompositeReporter::ReportCpuUsage(const ScenarioResult& result) {
reporters_[i]->ReportCpuUsage(result); reporters_[i]->ReportCpuUsage(result);
} }
} }
void GprLogReporter::ReportQPS(const ScenarioResult& result) { void GprLogReporter::ReportQPS(const ScenarioResult& result) {
gpr_log(GPR_INFO, "QPS: %.1f", result.summary().qps()); gpr_log(GPR_INFO, "QPS: %.1f", result.summary().qps());
} }

Loading…
Cancel
Save