Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: tools/deep_memory_profiler/subcommands/policies.py

Issue 141563014: Make dmprof handle long runs better (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add notes to DumpList class documentation. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/deep_memory_profiler/subcommands/cat.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import datetime 5 import datetime
6 import json 6 import json
7 import logging 7 import logging
8 import sys 8 import sys
9 9
10 from lib.bucket import BUCKET_ID, COMMITTED 10 from lib.bucket import BUCKET_ID, COMMITTED
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 max_components = max(max_components, len(policy_set[label].components)) 292 max_components = max(max_components, len(policy_set[label].components))
293 293
294 for label in sorted(policy_set): 294 for label in sorted(policy_set):
295 components = policy_set[label].components 295 components = policy_set[label].components
296 if len(policy_set) > 1: 296 if len(policy_set) > 1:
297 out.write('%s%s\n' % (label, ',' * (max_components - 1))) 297 out.write('%s%s\n' % (label, ',' * (max_components - 1)))
298 out.write('%s%s\n' % ( 298 out.write('%s%s\n' % (
299 ','.join(components), ',' * (max_components - len(components)))) 299 ','.join(components), ',' * (max_components - len(components))))
300 300
301 LOGGER.info('Applying a policy %s to...' % label) 301 LOGGER.info('Applying a policy %s to...' % label)
302 for dump in dumps: 302 for index, dump in enumerate(dumps):
303 if index == 0:
304 first_dump_time = dump.time
303 component_sizes = self._apply_policy( 305 component_sizes = self._apply_policy(
304 dump, pfn_counts_dict, policy_set[label], bucket_set, dumps[0].time) 306 dump, pfn_counts_dict, policy_set[label], bucket_set,
307 first_dump_time)
305 s = [] 308 s = []
306 for c in components: 309 for c in components:
307 if c in ('hour', 'minute', 'second'): 310 if c in ('hour', 'minute', 'second'):
308 if isinstance(component_sizes[c], str): 311 if isinstance(component_sizes[c], str):
309 s.append('%s' % component_sizes[c]) 312 s.append('%s' % component_sizes[c])
310 else: 313 else:
311 s.append('%05.5f' % (component_sizes[c])) 314 s.append('%05.5f' % (component_sizes[c]))
312 else: 315 else:
313 s.append('%05.5f' % (component_sizes[c] / 1024.0 / 1024.0)) 316 s.append('%05.5f' % (component_sizes[c] / 1024.0 / 1024.0))
314 out.write('%s%s\n' % ( 317 out.write('%s%s\n' % (
(...skipping 19 matching lines...) Expand all
334 'policies': {}, 337 'policies': {},
335 } 338 }
336 339
337 for label in sorted(policy_set): 340 for label in sorted(policy_set):
338 json_base['policies'][label] = { 341 json_base['policies'][label] = {
339 'legends': policy_set[label].components, 342 'legends': policy_set[label].components,
340 'snapshots': [], 343 'snapshots': [],
341 } 344 }
342 345
343 LOGGER.info('Applying a policy %s to...' % label) 346 LOGGER.info('Applying a policy %s to...' % label)
344 for dump in dumps: 347 for index, dump in enumerate(dumps):
348 if index == 0:
349 first_dump_time = dump.time
345 component_sizes = self._apply_policy( 350 component_sizes = self._apply_policy(
346 dump, pfn_counts_dict, policy_set[label], bucket_set, dumps[0].time) 351 dump, pfn_counts_dict, policy_set[label], bucket_set,
352 first_dump_time)
347 component_sizes['dump_path'] = dump.path 353 component_sizes['dump_path'] = dump.path
348 component_sizes['dump_time'] = datetime.datetime.fromtimestamp( 354 component_sizes['dump_time'] = datetime.datetime.fromtimestamp(
349 dump.time).strftime('%Y-%m-%d %H:%M:%S') 355 dump.time).strftime('%Y-%m-%d %H:%M:%S')
350 json_base['policies'][label]['snapshots'].append(component_sizes) 356 json_base['policies'][label]['snapshots'].append(component_sizes)
351 357
352 bucket_set.clear_component_cache() 358 bucket_set.clear_component_cache()
353 359
354 json.dump(json_base, out, indent=2, sort_keys=True) 360 json.dump(json_base, out, indent=2, sort_keys=True)
355 361
356 return 0 362 return 0
(...skipping 17 matching lines...) Expand all
374 out.write('%s for %s:\n' % (label, dump.path)) 380 out.write('%s for %s:\n' % (label, dump.path))
375 for c in policy_set[label].components: 381 for c in policy_set[label].components:
376 if c in ['hour', 'minute', 'second']: 382 if c in ['hour', 'minute', 'second']:
377 out.write('%40s %12.3f\n' % (c, component_sizes[c])) 383 out.write('%40s %12.3f\n' % (c, component_sizes[c]))
378 else: 384 else:
379 out.write('%40s %12d\n' % (c, component_sizes[c])) 385 out.write('%40s %12d\n' % (c, component_sizes[c]))
380 386
381 bucket_set.clear_component_cache() 387 bucket_set.clear_component_cache()
382 388
383 return 0 389 return 0
OLDNEW
« no previous file with comments | « tools/deep_memory_profiler/subcommands/cat.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698