diff --git a/python/examples/pipeline/imdb_model_ensemble/analyse.py b/python/examples/pipeline/imdb_model_ensemble/analyse.py new file mode 100644 index 0000000000000000000000000000000000000000..61511cea28e94d7e1fa3ef379075d47c90333e05 --- /dev/null +++ b/python/examples/pipeline/imdb_model_ensemble/analyse.py @@ -0,0 +1,32 @@ +# 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. + +from paddle_serving_server.pipeline import Analyst +import json +import logging +import sys + +logging.basicConfig(level=logging.INFO) + +if __name__ == "__main__": + if len(sys.argv) < 3: + print("Usage: python analyse.py ") + exit(1) + log_filename = sys.argv[1] + trace_filename = sys.argv[2] + analyst = Analyst(log_filename) + analyst.save_trace(trace_filename) + op_analyst = analyst.get_op_analyst() + op_concurrency = op_analyst.concurrency_analysis("analyse.yaml") + print(json.dumps(op_concurrency, indent=2, separators=(',', ':'))) diff --git a/python/examples/pipeline/imdb_model_ensemble/analyse.yaml b/python/examples/pipeline/imdb_model_ensemble/analyse.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9dd28f03ccea3239658cffb31aa520bb190775bf --- /dev/null +++ b/python/examples/pipeline/imdb_model_ensemble/analyse.yaml @@ -0,0 +1,4 @@ +bow: + midp: 0 +cnn: + midp: 1 diff --git a/python/examples/pipeline/imdb_model_ensemble/test_pipeline_client.py b/python/examples/pipeline/imdb_model_ensemble/test_pipeline_client.py index 53f2e777e3727459005800c1ce6e5733c14243c8..9cf476c4705c2267aa42337f90970d9fd051b7fd 100644 --- a/python/examples/pipeline/imdb_model_ensemble/test_pipeline_client.py +++ b/python/examples/pipeline/imdb_model_ensemble/test_pipeline_client.py @@ -20,18 +20,12 @@ client.connect(['127.0.0.1:18080']) words = 'i am very sad | 0' futures = [] -for i in range(1): +for i in range(100): futures.append( client.predict( - feed_dict={"words": words}, - fetch=["prediction"], - asyn=True, - profile=True)) + feed_dict={"words": words}, fetch=["prediction"], asyn=True)) for f in futures: res = f.result() if res["ecode"] != 0: - print(res) - exit(1) - -print(res) + print("predict failed: {}".format(res))