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

Unified Diff: tools/memory_inspector/memory_inspector/frontends/command_line.py

Issue 559113002: Truncate process_name if greater than 50 charcters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code change following review Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/memory_inspector/memory_inspector/frontends/command_line.py
diff --git a/tools/memory_inspector/memory_inspector/frontends/command_line.py b/tools/memory_inspector/memory_inspector/frontends/command_line.py
index 8b418d90f527d57dff6c3bcd5beebf67773361e9..7987e9c607d7519a3102e8a65bba96108be04742 100644
--- a/tools/memory_inspector/memory_inspector/frontends/command_line.py
+++ b/tools/memory_inspector/memory_inspector/frontends/command_line.py
@@ -86,8 +86,8 @@ def main():
stats = process.GetStats()
run_time_min, run_time_sec = divmod(stats.run_time, 60)
print '%10s : %-50s : %6s m %2s s %8s %12s' % (
- process.pid, process.name, run_time_min, run_time_sec,
- stats.threads, stats.vm_rss)
+ process.pid, _Truncate(process.name, 50), run_time_min,
+ run_time_sec, stats.threads, stats.vm_rss)
return 0
if not options.process_id:
@@ -131,7 +131,7 @@ def _ListProcessStats(process):
stats = process.GetStats()
run_time_min, run_time_sec = divmod(stats.run_time, 60)
print '%10s : %-50s : %6s m %2s s %8s %12s %13s %11s' % (
- process.pid, process.name, run_time_min, run_time_sec,
+ process.pid, _Truncate(process.name, 50), run_time_min, run_time_sec,
stats.threads, stats.cpu_usage, stats.vm_rss, stats.page_faults)
time.sleep(1)
@@ -167,3 +167,7 @@ def _ListProcessClassifiedMmaps(process, mmap_rule):
print json.dumps(classified_results_tree, cls=serialization.Encoder)
+def _Truncate(name, max_length):
+ if len(name) <= max_length:
+ return name
+ return '%s...' % name[0:(max_length - 3)]
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698