##// END OF EJS Templates
core: added more accurate time measurement for called functions
marcink -
r3853:5f8c0244 default
parent child Browse files
Show More
@@ -130,7 +130,7 b' def pre_request(worker, req):'
130 130 def post_request(worker, req, environ, resp):
131 131 total_time = time.time() - worker.start_time
132 132 worker.log.debug(
133 "GNCRN POST WORKER [cnt:%s]: %s %s resp: %s, Load Time: %.3fs",
133 "GNCRN POST WORKER [cnt:%s]: %s %s resp: %s, Load Time: %.4fs",
134 134 worker.nr, req.method, req.path, resp.status_code, total_time)
135 135
136 136
@@ -101,7 +101,7 b' def search(request, apiuser, search_quer'
101 101 searcher.cleanup()
102 102
103 103 if not search_result['error']:
104 data['execution_time'] = '%s results (%.3f seconds)' % (
104 data['execution_time'] = '%s results (%.4f seconds)' % (
105 105 search_result['count'],
106 106 search_result['runtime'])
107 107 else:
@@ -169,7 +169,7 b' class RepoFeedView(RepoAppView):'
169 169 else:
170 170 mime_type, feed = generate_atom_feed(*args)
171 171
172 log.debug('Repo ATOM feed computed in %.3fs',
172 log.debug('Repo ATOM feed computed in %.4fs',
173 173 inv_context_manager.compute_time)
174 174
175 175 response = Response(feed)
@@ -235,7 +235,7 b' class RepoFeedView(RepoAppView):'
235 235 else:
236 236 mime_type, feed = generate_rss_feed(*args)
237 237 log.debug(
238 'Repo RSS feed computed in %.3fs', inv_context_manager.compute_time)
238 'Repo RSS feed computed in %.4fs', inv_context_manager.compute_time)
239 239
240 240 response = Response(feed)
241 241 response.content_type = mime_type
@@ -98,7 +98,7 b' class RepoSummaryView(RepoAppView):'
98 98 instance = generate_repo_readme(*args)
99 99
100 100 log.debug(
101 'Repo readme generated and computed in %.3fs',
101 'Repo readme generated and computed in %.4fs',
102 102 inv_context_manager.compute_time)
103 103 return instance
104 104
@@ -88,7 +88,7 b' def perform_search(request, tmpl_context'
88 88 search_tags = searcher.extract_search_tags(search_query)
89 89
90 90 if not search_result['error']:
91 execution_time = '%s results (%.3f seconds)' % (
91 execution_time = '%s results (%.4f seconds)' % (
92 92 search_result['count'],
93 93 search_result['runtime'])
94 94 elif not errors:
@@ -762,7 +762,7 b' def authenticate(username, password, env'
762 762 plugin_user = compute_auth('auth', plugin.name, username, (password or ''))
763 763
764 764 auth_time = time.time() - start
765 log.debug('Authentication for plugin `%s` completed in %.3fs, '
765 log.debug('Authentication for plugin `%s` completed in %.4fs, '
766 766 'expiration time of fetched cache %.1fs.',
767 767 plugin.get_id(), auth_time, cache_ttl)
768 768
@@ -1233,7 +1233,7 b' class AuthUser(object):'
1233 1233 for k in result:
1234 1234 result_repr.append((k, len(result[k])))
1235 1235 total = time.time() - start
1236 log.debug('PERMISSION tree for user %s computed in %.3fs: %s',
1236 log.debug('PERMISSION tree for user %s computed in %.4fs: %s',
1237 1237 user, total, result_repr)
1238 1238
1239 1239 return result
@@ -2402,7 +2402,7 b' class Repository(Base, BaseModel):'
2402 2402 instance = get_instance_cached(*args)
2403 2403
2404 2404 log.debug(
2405 'Repo instance fetched in %.3fs', inv_context_manager.compute_time)
2405 'Repo instance fetched in %.4fs', inv_context_manager.compute_time)
2406 2406 return instance
2407 2407
2408 2408 def _get_instance(self, cache=True, config=None):
@@ -2425,7 +2425,7 b' class Repository(Base, BaseModel):'
2425 2425 instance = get_instance_cached(*args)
2426 2426
2427 2427 log.debug(
2428 'Repo instance fetched in %.3fs', inv_context_manager.compute_time)
2428 'Repo instance fetched in %.4fs', inv_context_manager.compute_time)
2429 2429 return instance
2430 2430
2431 2431 def _get_instance(self, cache=True, config=None):
@@ -2425,7 +2425,7 b' class Repository(Base, BaseModel):'
2425 2425 instance = get_instance_cached(*args)
2426 2426
2427 2427 log.debug(
2428 'Repo instance fetched in %.3fs', inv_context_manager.compute_time)
2428 'Repo instance fetched in %.4fs', inv_context_manager.compute_time)
2429 2429 return instance
2430 2430
2431 2431 def _get_instance(self, cache=True, config=None):
@@ -1178,7 +1178,7 b' def cache_diff(cached_diff_file, diff, c'
1178 1178 log.warn('Failed to save cache', exc_info=True)
1179 1179 _cleanup_cache_file(cached_diff_file)
1180 1180
1181 log.debug('Saved diff cache under %s in %.3fs', cached_diff_file, time.time() - start)
1181 log.debug('Saved diff cache under %s in %.4fs', cached_diff_file, time.time() - start)
1182 1182
1183 1183
1184 1184 def load_cached_diff(cached_diff_file):
@@ -1221,7 +1221,7 b' def load_cached_diff(cached_diff_file):'
1221 1221 _cleanup_cache_file(cached_diff_file)
1222 1222 return default_struct
1223 1223
1224 log.debug('Loaded diff cache from %s in %.3fs', cached_diff_file, time.time() - start)
1224 log.debug('Loaded diff cache from %s in %.4fs', cached_diff_file, time.time() - start)
1225 1225
1226 1226 return data
1227 1227
@@ -45,7 +45,7 b' class RequestWrapperTween(object):'
45 45 end = time.time()
46 46 total = end - start
47 47 log.info(
48 'IP: %s %s Request to %s time: %.3fs [%s]',
48 'IP: %s %s Request to %s time: %.4fs [%s]',
49 49 get_ip_addr(request.environ), request.environ.get('REQUEST_METHOD'),
50 50 safe_str(get_access_path(request.environ)), total,
51 51 get_user_agent(request. environ)
@@ -354,7 +354,7 b' class SimpleVCS(object):'
354 354 'vcs_permissions', plugin_id, action, user.user_id, repo_name, ip_addr)
355 355
356 356 auth_time = time.time() - start
357 log.debug('Permissions for plugin `%s` completed in %.3fs, '
357 log.debug('Permissions for plugin `%s` completed in %.4fs, '
358 358 'expiration time of fetched cache %.1fs.',
359 359 plugin_id, auth_time, cache_ttl)
360 360
@@ -251,7 +251,7 b' class InvalidationContext(object):'
251 251 result = heavy_compute(*args)
252 252
253 253 compute_time = inv_context_manager.compute_time
254 log.debug('result computed in %.3fs', compute_time)
254 log.debug('result computed in %.4fs', compute_time)
255 255
256 256 # To send global invalidation signal, simply run
257 257 CacheKey.set_invalidate(invalidation_namespace)
@@ -289,7 +289,8 b' class InvalidationContext(object):'
289 289 log.debug('Fetched cache obj %s using %s cache key.', cache_obj, self.cache_key)
290 290 invalidation_namespace = invalidation_namespace or self.invalidation_namespace
291 291 if not cache_obj:
292 cache_obj = CacheKey(self.cache_key, cache_args=invalidation_namespace)
292 new_cache_args = invalidation_namespace
293 cache_obj = CacheKey(self.cache_key, cache_args=new_cache_args)
293 294 return cache_obj
294 295
295 296 def __enter__(self):
@@ -158,7 +158,8 b' class GitCommit(base.BaseCommit):'
158 158
159 159 @LazyProperty
160 160 def branch(self):
161 branches = safe_unicode(self._remote.branch(self.raw_id))
161 branches = self._remote.branch(self.raw_id)
162
162 163 if branches:
163 164 # actually commit can have multiple branches in git
164 165 return safe_unicode(branches[0])
@@ -154,7 +154,7 b' class RemoteRepo(object):'
154 154 self.url, name, args, context_uid)
155 155 result = _remote_call(self.url, payload, EXCEPTIONS_MAP, self._session)
156 156 if self._call_with_logging:
157 log.debug('Call %s@%s took: %.3fs. wire_context: %s',
157 log.debug('Call %s@%s took: %.4fs. wire_context: %s',
158 158 self.url, name, time.time()-start, context_uid)
159 159 return result
160 160
@@ -2481,7 +2481,7 b' class Repository(Base, BaseModel):'
2481 2481 else:
2482 2482 instance = get_instance_cached(*args)
2483 2483
2484 log.debug('Repo instance fetched in %.3fs', inv_context_manager.compute_time)
2484 log.debug('Repo instance fetched in %.4fs', inv_context_manager.compute_time)
2485 2485 return instance
2486 2486
2487 2487 def _get_instance(self, cache=True, config=None, repo_state_uid=None):
@@ -242,7 +242,7 b' class SettingsModel(BaseModel):'
242 242 region.invalidate()
243 243
244 244 result = _get_all_settings('rhodecode_settings', key)
245 log.debug('Fetching app settings for key: %s took: %.3fs', key,
245 log.debug('Fetching app settings for key: %s took: %.4fs', key,
246 246 inv_context_manager.compute_time)
247 247
248 248 return result
@@ -43,7 +43,7 b' def main(server, repeat, pages):'
43 43 t = timeit.Timer(stmt=stmt, setup="import requests")
44 44
45 45 result = t.repeat(repeat=repeat, number=1)
46 print(" %.3f (min) - %.3f (max) - %.3f (avg)\n" %
46 print(" %.4f (min) - %.4f (max) - %.4f (avg)\n" %
47 47 (min(result), max(result), sum(result) / len(result)))
48 48
49 49
@@ -198,6 +198,6 b" if __name__ == '__main__':"
198 198 print('take {}'.format(i))
199 199 test_clone_with_credentials(repo=sys.argv[1], method=METHOD,
200 200 seq=seq, backend=backend)
201 print('time taken %.3f' % (time.time() - s))
201 print('time taken %.4f' % (time.time() - s))
202 202 except Exception as e:
203 203 sys.exit('stop on %s' % e)
General Comments 0
You need to be logged in to leave comments. Login now