mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1445383 - update ccache stats parser for ccache 3.4 and 3.5 r=froydnj
MozReview-Commit-ID: KTr9RhkJN5B --HG-- extra : rebase_source : b384a7e79f2e349a29942cf85f52aa306ddaa3c8
This commit is contained in:
parent
ee92007fde
commit
542cefeac8
@ -757,6 +757,8 @@ class CCacheStats(object):
|
||||
STATS_KEYS = [
|
||||
# (key, description)
|
||||
# Refer to stats.c in ccache project for all the descriptions.
|
||||
('stats_zero_time', 'stats zero time'),
|
||||
('stats_updated', 'stats updated'),
|
||||
('cache_hit_direct', 'cache hit (direct)'),
|
||||
('cache_hit_preprocessed', 'cache hit (preprocessed)'),
|
||||
('cache_hit_rate', 'cache hit rate'),
|
||||
@ -838,6 +840,13 @@ class CCacheStats(object):
|
||||
|
||||
@staticmethod
|
||||
def _parse_value(raw_value):
|
||||
try:
|
||||
# ccache calls strftime with '%c' (src/stats.c)
|
||||
ts = time.strptime(raw_value, '%c')
|
||||
return int(time.mktime(ts))
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
value = raw_value.split()
|
||||
unit = ''
|
||||
if len(value) == 1:
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
from mozunit import main
|
||||
@ -174,6 +175,30 @@ class TestCcacheStats(unittest.TestCase):
|
||||
max cache size 5.0 GB
|
||||
"""
|
||||
|
||||
# Substitute a locally-generated timestamp because the timestamp format is
|
||||
# locale-dependent.
|
||||
STAT8 = """
|
||||
cache directory /home/psimonyi/.ccache
|
||||
primary config /home/psimonyi/.ccache/ccache.conf
|
||||
secondary config (readonly) /etc/ccache.conf
|
||||
stats zero time {timestamp}
|
||||
cache hit (direct) 571
|
||||
cache hit (preprocessed) 1203
|
||||
cache miss 11747
|
||||
cache hit rate 13.12 %
|
||||
called for link 623
|
||||
called for preprocessing 7194
|
||||
compile failed 32
|
||||
preprocessor error 137
|
||||
bad compiler arguments 4
|
||||
autoconf compile/link 348
|
||||
no input file 162
|
||||
cleanups performed 77
|
||||
files in cache 13464
|
||||
cache size 6.2 GB
|
||||
max cache size 7.0 GB
|
||||
""".format(timestamp=time.strftime('%c'))
|
||||
|
||||
def test_parse_garbage_stats_message(self):
|
||||
self.assertRaises(ValueError, CCacheStats, self.STAT_GARBAGE)
|
||||
|
||||
@ -231,5 +256,10 @@ class TestCcacheStats(unittest.TestCase):
|
||||
stat7 = CCacheStats(self.STAT7)
|
||||
self.assertTrue(stat7)
|
||||
|
||||
def test_stats_version34(self):
|
||||
# Test parsing 3.4 output.
|
||||
stat8 = CCacheStats(self.STAT8)
|
||||
self.assertTrue(stat8)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user