diff --git a/core/cube/cube-api/src/cube_cli.cpp b/core/cube/cube-api/src/cube_cli.cpp index eee4b0c31ad83ca69d242e81bae3ce4ecfb5bf1a..19e77c90a441b1d0877575ac1d9c313e1579c08b 100644 --- a/core/cube/cube-api/src/cube_cli.cpp +++ b/core/cube/cube-api/src/cube_cli.cpp @@ -188,6 +188,7 @@ int run_m(int argc, char** argv) { request_list.resize(thread_num); time_list.resize(thread_num); std::vector thread_pool; + TIME_FLAG(main_start); for (int i = 0; i < thread_num; i++) { thread_pool.push_back(new std::thread(run, argc, argv, i)); } @@ -195,6 +196,7 @@ int run_m(int argc, char** argv) { thread_pool[i]->join(); delete thread_pool[i]; } + TIME_FLAG(main_end); uint64_t sum_time = 0; uint64_t max_time = 0; uint64_t min_time = 1000000; @@ -210,12 +212,14 @@ int run_m(int argc, char** argv) { request_num += request_list[i]; } uint64_t mean_time = sum_time / thread_num; + uint64_t main_time = time_diff(main_start, main_end); LOG(INFO) << thread_num << " thread seek cost" << " avg = " << std::to_string(mean_time) << " max = " << std::to_string(max_time) << " min = " << std::to_string(min_time); - LOG(INFO) << " total_request = " << std::to_string(request_num) << " speed = " - << std::to_string(1000000 * thread_num / mean_time) // mean_time us + LOG(INFO) << " total_request = " << std::to_string(request_num) + << " speed = " << std::to_string(request_num * 1000000 / + main_time) // mean_time us << " query per second"; return 0; } diff --git a/python/examples/criteo_ctr_with_cube/benchmark_cube.sh b/python/examples/criteo_ctr_with_cube/benchmark_cube.sh new file mode 100755 index 0000000000000000000000000000000000000000..aaf1dccea787ba0a19f1b341a8275aabf1a2d8d2 --- /dev/null +++ b/python/examples/criteo_ctr_with_cube/benchmark_cube.sh @@ -0,0 +1,31 @@ +rm profile_log + +#wget https://paddle-serving.bj.bcebos.com/unittest/ctr_cube_unittest.tar.gz --no-check-certificate +tar xf ctr_cube_unittest.tar.gz +mv models/ctr_client_conf ./ +mv models/ctr_serving_model_kv ./ +mv models/data ./cube/ + +#wget https://paddle-serving.bj.bcebos.com/others/cube_app.tar.gz --no-check-certificate +tar xf cube_app.tar.gz +mv cube_app/cube* ./cube/ +sh cube_prepare.sh & + +cp ../../../build_server/core/cube/cube-api/cube-cli . +python gen_key.py + +for thread_num in 1 +do +for batch_size in 1 +do + ./cube-cli -config_file ./cube/conf/cube.conf -keys key -dict test_dict -thread_num $thread_num --batch $batch_size > profile 2>&1 + echo "batch size : $batch_size" + echo "thread num : $thread_num" + echo "========================================" + echo "batch size : $batch_size" >> profile_log + echo "thread num : $thread_num" >> profile_log + tail -n 2 profile >> profile_log +done +done + +ps -ef|grep 'cube'|grep -v grep|cut -c 9-15 | xargs kill -9 diff --git a/python/examples/criteo_ctr_with_cube/gen_key.py b/python/examples/criteo_ctr_with_cube/gen_key.py new file mode 100644 index 0000000000000000000000000000000000000000..115d81701fb2c8b78085c4c88a685dda992f2c27 --- /dev/null +++ b/python/examples/criteo_ctr_with_cube/gen_key.py @@ -0,0 +1,20 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys +import random + +with open("key", "w") as f: + for i in range(1000000): + f.write("{}\n".format(random.randint(0, 999999)))