| Index: scripts/slave/performance_log_processor.py
|
| diff --git a/scripts/slave/process_log_utils.py b/scripts/slave/performance_log_processor.py
|
| similarity index 99%
|
| rename from scripts/slave/process_log_utils.py
|
| rename to scripts/slave/performance_log_processor.py
|
| index 241cedeec2a6aa5369aeb205ab345159ef442a11..d25b83cec38393f73aecf0ca263f21a3c5e6ad7b 100644
|
| --- a/scripts/slave/process_log_utils.py
|
| +++ b/scripts/slave/performance_log_processor.py
|
| @@ -22,6 +22,8 @@ import os
|
| import re
|
|
|
| from common import chromium_utils
|
| +
|
| +# TODO(crbug.com/403564).
|
| import config
|
|
|
| # Status codes that can be returned by the evaluateCommand method.
|
| @@ -30,62 +32,6 @@ import config
|
| SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION, RETRY = range(6)
|
|
|
|
|
| -def _FormatFloat(number):
|
| - """Formats float with two decimal points."""
|
| - if number:
|
| - return '%.2f' % number
|
| - else:
|
| - return '0.00'
|
| -
|
| -
|
| -def _FormatPercentage(ratio):
|
| - """Formats a number as a string with a percentage (e.g. 0.5 => "50%")."""
|
| - return '%s%%' % _FormatFloat(100 * ratio)
|
| -
|
| -
|
| -def _Divide(x, y):
|
| - """Divides with float division, or returns infinity if denominator is 0."""
|
| - if y == 0:
|
| - return float('inf')
|
| - return float(x) / y
|
| -
|
| -
|
| -def _FormatHumanReadable(number):
|
| - """Formats a float into three significant figures, using metric suffixes.
|
| -
|
| - Only m, k, and M prefixes (for 1/1000, 1000, and 1,000,000) are used.
|
| - Examples:
|
| - 0.0387 => 38.7m
|
| - 1.1234 => 1.12
|
| - 10866 => 10.8k
|
| - 682851200 => 683M
|
| - """
|
| - metric_prefixes = {-3: 'm', 0: '', 3: 'k', 6: 'M'}
|
| - scientific = '%.2e' % float(number) # 6.83e+005
|
| - e_idx = scientific.find('e') # 4, or 5 if negative
|
| - digits = float(scientific[:e_idx]) # 6.83
|
| - exponent = int(scientific[e_idx + 1:]) # int('+005') = 5
|
| - while exponent % 3:
|
| - digits *= 10
|
| - exponent -= 1
|
| - while exponent > 6:
|
| - digits *= 10
|
| - exponent -= 1
|
| - while exponent < -3:
|
| - digits /= 10
|
| - exponent += 1
|
| - if digits >= 100:
|
| - # Don't append a meaningless '.0' to an integer number.
|
| - digits = int(digits)
|
| - # Exponent is now divisible by 3, between -3 and 6 inclusive: (-3, 0, 3, 6).
|
| - return '%s%s' % (digits, metric_prefixes[exponent])
|
| -
|
| -
|
| -def _JoinWithSpacesAndNewLine(words):
|
| - """Joins a list of words together with spaces."""
|
| - return ' '.join(str(w) for w in words) + '\n'
|
| -
|
| -
|
| class PerformanceLogProcessor(object):
|
| """Parent class for performance log parsers.
|
|
|
| @@ -840,3 +786,59 @@ class GraphingPageCyclerLogProcessor(GraphingLogProcessor):
|
|
|
| filename = '%s_%s.dat' % (self._revision, trace_name)
|
| return {filename: file_data}
|
| +
|
| +
|
| +def _FormatFloat(number):
|
| + """Formats float with two decimal points."""
|
| + if number:
|
| + return '%.2f' % number
|
| + else:
|
| + return '0.00'
|
| +
|
| +
|
| +def _FormatPercentage(ratio):
|
| + """Formats a number as a string with a percentage (e.g. 0.5 => "50%")."""
|
| + return '%s%%' % _FormatFloat(100 * ratio)
|
| +
|
| +
|
| +def _Divide(x, y):
|
| + """Divides with float division, or returns infinity if denominator is 0."""
|
| + if y == 0:
|
| + return float('inf')
|
| + return float(x) / y
|
| +
|
| +
|
| +def _FormatHumanReadable(number):
|
| + """Formats a float into three significant figures, using metric suffixes.
|
| +
|
| + Only m, k, and M prefixes (for 1/1000, 1000, and 1,000,000) are used.
|
| + Examples:
|
| + 0.0387 => 38.7m
|
| + 1.1234 => 1.12
|
| + 10866 => 10.8k
|
| + 682851200 => 683M
|
| + """
|
| + metric_prefixes = {-3: 'm', 0: '', 3: 'k', 6: 'M'}
|
| + scientific = '%.2e' % float(number) # 6.83e+005
|
| + e_idx = scientific.find('e') # 4, or 5 if negative
|
| + digits = float(scientific[:e_idx]) # 6.83
|
| + exponent = int(scientific[e_idx + 1:]) # int('+005') = 5
|
| + while exponent % 3:
|
| + digits *= 10
|
| + exponent -= 1
|
| + while exponent > 6:
|
| + digits *= 10
|
| + exponent -= 1
|
| + while exponent < -3:
|
| + digits /= 10
|
| + exponent += 1
|
| + if digits >= 100:
|
| + # Don't append a meaningless '.0' to an integer number.
|
| + digits = int(digits)
|
| + # Exponent is now divisible by 3, between -3 and 6 inclusive: (-3, 0, 3, 6).
|
| + return '%s%s' % (digits, metric_prefixes[exponent])
|
| +
|
| +
|
| +def _JoinWithSpacesAndNewLine(words):
|
| + """Joins a list of words together with spaces."""
|
| + return ' '.join(str(w) for w in words) + '\n'
|
|
|