TEST(core, lpc_perf_test_sync) { std::chrono::steady_clock clock; auto tic = clock.now(); int round = 1000000; int concurrency = 10; int total_query_count = round * concurrency; std::vector<task_ptr> tasks; std::vector<std::string> results; for (int i = 0; i < round; i++) { results.resize(concurrency); for (int j = 0; j < concurrency; j++) { auto task = ::dsn::tasking::enqueue( LPC_TEST_HASH, nullptr, [&results, j]() { std::string r = dsn_get_current_app_data_dir(); results[j] = std::move(r); } ); tasks.push_back(task); } for (auto& t : tasks) t->wait(); tasks.clear(); } auto toc = clock.now(); auto time_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(toc - tic).count(); std::cout << "lpc-sync perf test: throughput = " << total_query_count * 1000000000llu / time_ns << " #/s, avg latency = " << time_ns / total_query_count << " ns" << std::endl; }
error_code deploy_svc_service_impl::start() { std::string pdir = utils::filesystem::path_combine(dsn_get_current_app_data_dir(), "services"); _service_dir = dsn_config_get_value_string("deploy.service", "deploy_dir", pdir.c_str(), "where to put temporal deployment resources" ); // load clusters const char* clusters[100]; int sz = 100; int count = dsn_config_get_all_keys("deploy.service.clusters", clusters, &sz); dassert(count <= 100, "too many clusters"); for (int i = 0; i < count; i++) { std::string cluster_name = dsn_config_get_value_string( clusters[i], "name", "", "cluster name" ); if (nullptr != get_cluster(cluster_name)) { derror("cluster %s already defined", cluster_name.c_str()); return ERR_CLUSTER_ALREADY_EXIST; } std::string cluster_factory_type = dsn_config_get_value_string( clusters[i], "factory", "", "factory name to create the target cluster scheduler" ); auto cluster = ::dsn::utils::factory_store<cluster_scheduler>::create( cluster_factory_type.c_str(), PROVIDER_TYPE_MAIN ); if (nullptr == cluster) { derror("cluster type %s is not defined", cluster_factory_type.c_str()); return ERR_OBJECT_NOT_FOUND; } std::shared_ptr<cluster_ex> ce(new cluster_ex); ce->scheduler.reset(cluster); ce->cluster.name = cluster_name; ce->cluster.type = cluster->type(); _clusters[cluster_name] = ce; } _cli_deploy = dsn_cli_app_register( "deploy", "deploy deploy_request(in json format)", "deploy an app via our deployment service", (void*)this, [](void *context, int argc, const char **argv, dsn_cli_reply *reply) { auto this_ = (deploy_svc_service_impl*)context; this_->on_deploy_cli(context, argc, argv, reply); }, __svc_cli_freeer__ ); _cli_undeploy = dsn_cli_app_register( "undeploy", "undeploy service_name(in json format)", "undeploy an app via our deployment service", (void*)this, [](void *context, int argc, const char **argv, dsn_cli_reply *reply) { auto this_ = (deploy_svc_service_impl*)context; this_->on_undeploy_cli(context, argc, argv, reply); }, __svc_cli_freeer__ ); _cli_get_service_list = dsn_cli_app_register( "service_list", "service_list package_id(in json format)", "get service list of a package via our deployment service", (void*)this, [](void *context, int argc, const char **argv, dsn_cli_reply *reply) { auto this_ = (deploy_svc_service_impl*)context; this_->on_get_service_list_cli(context, argc, argv, reply); }, __svc_cli_freeer__ ); _cli_get_service_info = dsn_cli_app_register( "service_info", "service_info service_name(in json format)", "get service info of a service via our deployment service", (void*)this, [](void *context, int argc, const char **argv, dsn_cli_reply *reply) { auto this_ = (deploy_svc_service_impl*)context; this_->on_get_service_info_cli(context, argc, argv, reply); }, __svc_cli_freeer__ ); _cli_get_cluster_list = dsn_cli_app_register( "cluster_list", "cluster_list format(in json format)", "get cluster list with a specific format via our deployment service", (void*)this, [](void *context, int argc, const char **argv, dsn_cli_reply *reply) { auto this_ = (deploy_svc_service_impl*)context; this_->on_get_cluster_list_cli(context, argc, argv, reply); }, __svc_cli_freeer__ ); return ERR_OK; }