namespace {
-constexpr const char SERVER_PROC_NAME[] = "org.tizen.appfw.rpc_port.benchmark";
-constexpr const char SERVER_BIN[] = "/usr/bin/rpc-port-benchmark-server";
+#define SERVER_PROC_NAME "org.tizen.appfw.rpc_port.benchmark"
+#define SERVER_BIN "/usr/bin/rpc-port-benchmark-server"
namespace bp = rpc_port::BenchmarkProxy::proxy;
exit(1);
}
- DoTest();
+ 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());
+ }
}
private:
- void DoTest() {
- int iters = options_->GetIters();
- int size = options_->GetSize();
+ void DoTest(int iters, int size) {
+ bool is_func = options_->IsFunction();
StartTime();
for (int i = 0; i < iters; i++) {
+ if (is_func) {
+ int ret = FakeFunction(std::string(size, 'a'));
+ if (ret != 0) {
+ _E("Invalid return");
+ break;
+ }
+
+ continue;
+ }
+
int ret = proxy_->Test(std::string(size, 'a'));
if (ret != 0) {
_E("Invalid return");
break;
}
}
- EndTime();
+ EndTime(iters, size);
+ }
+
+ int FakeFunction(std::string str) {
+ return 0;
}
void StartTime() {
start_ = std::chrono::system_clock::now();
}
- void EndTime() {
+ void EndTime(int iters, int size) {
std::chrono::duration<double> sec = std::chrono::system_clock::now() - start_;
- std::cout << "Iterations: " << std::to_string(options_->GetIters()) << std::endl;
- std::cout << "Data size: " << std::to_string(options_->GetSize()) << "Byte" << std::endl;
- std::cout << "Duration: " << sec.count() << "s" << std::endl;
- double t = options_->GetSize() * options_->GetIters() / sec.count() / 1024 / 1024;
- std::cout << "Throughput: " << std::to_string(t * 8) << "Mb/s" << std::endl;
- double l = sec.count() * 1000 / options_->GetIters();
- std::cout << "Latency: " << std::to_string(l) << "ms" << std::endl;
+ double t = size * iters * 8 / sec.count() / 1024 / 1024;
+ double l = sec.count() * 1000 / iters;
+
+ printf("%10d\t%10dByte\t%15.4fs\t%15.4fMb/s\t%15.4fms\n", iters, size,
+ sec.count(), t, l);
}
void ExecuteServer() {
if (server_pid_ == 0) {
setsid();
- char* argv[] = { strdup(SERVER_BIN), nullptr, nullptr };
+ char bin[] = { SERVER_BIN };
+ char* argv[] = { bin, nullptr, nullptr };
int ret = execv(argv[0], argv);
if (ret < 0) {
std::cerr << "execv() is failed. errno: " << errno << std::endl;
int main(int argc, char** argv) {
Tester tester;
- tester.Run(argc, argv);
+ try {
+ tester.Run(argc, argv);
+ } catch (const std::exception& e) {
+ std::cerr << "Exception occurred!!!" << e.what() << std::endl;
+ }
+
return 0;
}