class TestService : public bs::Benchmark::ServiceBase {
public:
class Factory : public bs::Benchmark::ServiceBase::Factory {
- public:
- virtual ~Factory() = default;
-
- std::unique_ptr<bs::Benchmark::ServiceBase>
- CreateService(std::string sender, std::string instance) {
- return std::unique_ptr<bs::Benchmark::ServiceBase>(
- new TestService(sender, instance));
- }
+ public:
+ virtual ~Factory() = default;
+
+ std::unique_ptr<bs::Benchmark::ServiceBase>
+ CreateService(std::string sender, std::string instance) {
+ return std::unique_ptr<bs::Benchmark::ServiceBase>(
+ new TestService(sender, instance));
+ }
};
TestService(std::string sender, std::string instance) :
try {
stub_.Listen(std::shared_ptr<bs::Benchmark::ServiceBase::Factory>(
new TestService::Factory()));
- } catch (const std::exception& e) {
- _E("stub listen is failed(%s)", e.what());
+ } catch (const bs::Exception&) {
+ _E("stub listen is failed");
}
+
g_main_loop_run(loop_);
}
void Run(int argc, char** argv) {
options_ = rpc_port::benchmark::Options::Parse(argc, argv);
if (!options_) {
- _E("options is nullptr");
- exit(1);
+ std::cerr << "options is unllptr" << std::endl;
+ return;
}
ExecuteServer();
try {
proxy_->Connect(true);
} catch (const bp::Exception& e) {
- _E("Connect() failed");
- exit(1);
+ std::cerr << "Connect() failed" << std::endl;
+ return;
+ } catch (const std::exception& e) {
+ std::cerr << "Connect() failed. " << e.what() << std::endl;
+ return;
}
printf("%15s\t%15s\t%15s\t\t%15s\t\t%15s\n", "Iterations", "Data size",
"Time", "Throughput", "Latency");
- if (options_->IsAll()) {
- DoTest(4000, 10);
- DoTest(4000, 20);
- DoTest(4000, 100);
- DoTest(4000, 200);
- DoTest(2000, 1000);
- DoTest(2000, 2000);
- DoTest(1000, 10000);
- DoTest(1000, 20000);
- DoTest(1000, 30000);
- DoTest(1000, 40000);
- DoTest(1000, 50000);
- DoTest(1000, 60000);
- DoTest(500, 100000);
- } else {
- DoTest(options_->GetIters(), options_->GetSize());
+
+ try {
+ if (options_->IsAll()) {
+ DoTest(4000, 10);
+ DoTest(4000, 20);
+ DoTest(4000, 100);
+ DoTest(4000, 200);
+ DoTest(2000, 1000);
+ DoTest(2000, 2000);
+ DoTest(1000, 10000);
+ DoTest(1000, 20000);
+ DoTest(1000, 30000);
+ DoTest(1000, 40000);
+ DoTest(1000, 50000);
+ DoTest(1000, 60000);
+ DoTest(500, 100000);
+ } else {
+ DoTest(options_->GetIters(), options_->GetSize());
+ }
+ } catch (const bp::Exception& e) {
+ std::cerr << "test failed" << std::endl;
}
}
}
void EndTime(int iters, int size) {
- std::chrono::duration<double> sec = std::chrono::system_clock::now() - start_;
+ std::chrono::duration<double> sec =
+ std::chrono::system_clock::now() - start_;
double t = size * iters * 8 / sec.count() / 1024 / 1024;
double l = sec.count() * 1000 / iters;
int main(int argc, char** argv) {
Tester tester;
- try {
- tester.Run(argc, argv);
- } catch (const std::exception& e) {
- std::cerr << "Exception occurred!!!" << e.what() << std::endl;
- }
-
+ tester.Run(argc, argv);
return 0;
}