mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1049263 - Do not report ccache stats unless ccache was used. r=glandium
This commit is contained in:
parent
6930452844
commit
5a7beb0db0
@ -611,6 +611,12 @@ class CCacheStats(object):
|
||||
|
||||
return '\n'.join(lines)
|
||||
|
||||
def __nonzero__(self):
|
||||
relative_values = [v for k, v in self._values.items()
|
||||
if k not in self.ABSOLUTE_KEYS]
|
||||
return (all(v >= 0 for v in relative_values) and
|
||||
any(v > 0 for v in relative_values))
|
||||
|
||||
@staticmethod
|
||||
def _format_value(v):
|
||||
if v > CCacheStats.GiB:
|
||||
|
@ -397,8 +397,9 @@ class Build(MachCommandBase):
|
||||
|
||||
if ccache_start and ccache_end:
|
||||
ccache_diff = ccache_end - ccache_start
|
||||
self.log(logging.INFO, 'ccache',
|
||||
{'msg': ccache_diff.hit_rate_message()}, "{msg}")
|
||||
if ccache_diff:
|
||||
self.log(logging.INFO, 'ccache',
|
||||
{'msg': ccache_diff.hit_rate_message()}, "{msg}")
|
||||
|
||||
if monitor.elapsed > 300:
|
||||
# Display a notification when the build completes.
|
||||
|
@ -73,6 +73,21 @@ class TestCcacheStats(unittest.TestCase):
|
||||
stats_diff = stats2 - stats1
|
||||
self.assertEqual(stats_diff.hit_rates(), (0.9, 0.05, 0.05))
|
||||
|
||||
def test_stats_contains_data(self):
|
||||
stats0 = CCacheStats(self.STAT0)
|
||||
stats1 = CCacheStats(self.STAT1)
|
||||
stats2 = CCacheStats(self.STAT2)
|
||||
stats_diff_zero = stats1 - stats1
|
||||
stats_diff_negative1 = stats0 - stats1
|
||||
stats_diff_negative2 = stats1 - stats2
|
||||
|
||||
self.assertFalse(stats0)
|
||||
self.assertTrue(stats1)
|
||||
self.assertTrue(stats2)
|
||||
self.assertFalse(stats_diff_zero)
|
||||
self.assertFalse(stats_diff_negative1)
|
||||
self.assertFalse(stats_diff_negative2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user