diff options
| author | Jenkins <jenkins@review.openstack.org> | 2014-07-11 18:22:06 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2014-07-11 18:22:06 +0000 |
| commit | bc6495c6a19abb67a9af9bc94e82e6c12b1a7b83 (patch) | |
| tree | 367c6f6c359ebed491cefae63ceabf8ddbe55093 /openstackclient/common | |
| parent | 70283744a04f868072edc0a31fe49a3122c4bc6e (diff) | |
| parent | 4844a257790deef231176557776754dde929f840 (diff) | |
| download | python-openstackclient-bc6495c6a19abb67a9af9bc94e82e6c12b1a7b83.tar.gz | |
Merge "Add basic timing support"
Diffstat (limited to 'openstackclient/common')
| -rw-r--r-- | openstackclient/common/clientmanager.py | 5 | ||||
| -rw-r--r-- | openstackclient/common/timing.py | 44 |
2 files changed, 47 insertions, 2 deletions
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py index b310f3ac..a2f85aff 100644 --- a/openstackclient/common/clientmanager.py +++ b/openstackclient/common/clientmanager.py @@ -49,7 +49,7 @@ class ClientManager(object): user_domain_id=None, user_domain_name=None, project_domain_id=None, project_domain_name=None, region_name=None, api_version=None, verify=True, - trust_id=None): + trust_id=None, timing=None): self._token = token self._url = url self._auth_url = auth_url @@ -67,6 +67,7 @@ class ClientManager(object): self._api_version = api_version self._trust_id = trust_id self._service_catalog = None + self.timing = timing # verify is the Requests-compatible form self._verify = verify @@ -116,7 +117,7 @@ def get_extension_modules(group): setattr( ClientManager, - ep.name, + module.API_NAME, ClientCache( getattr(sys.modules[ep.module_name], 'make_client', None) ), diff --git a/openstackclient/common/timing.py b/openstackclient/common/timing.py new file mode 100644 index 00000000..1c94682c --- /dev/null +++ b/openstackclient/common/timing.py @@ -0,0 +1,44 @@ +# 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. +# + +"""Timing Implementation""" + +import logging + +from cliff import lister + + +class Timing(lister.Lister): + """Show timing data""" + + log = logging.getLogger(__name__ + '.Timing') + + def take_action(self, parsed_args): + self.log.debug('take_action(%s)' % parsed_args) + + column_headers = ( + 'URL', + 'Seconds', + ) + + results = [] + total = 0.0 + for url, start, end in self.app.timing_data: + seconds = end - start + total += seconds + results.append((url, seconds)) + results.append(('Total', total)) + return ( + column_headers, + results, + ) |
