summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathew Robinson <chasinglogic@gmail.com>2019-01-18 07:20:27 -0500
committerMathew Robinson <chasinglogic@gmail.com>2019-01-18 07:20:27 -0500
commita99a4dc99354a8439cb8f9d088d2a7946048b4c7 (patch)
tree666f8b8963dbbb0786e0725d015dbb5e755336e9
parent1802707307b29b4cb0ee1459509fda5a5d87db6c (diff)
downloadmongo-cache-stats.tar.gz
WIP: make stats reporting run after buildcache-stats
-rw-r--r--SConstruct15
-rw-r--r--src/third_party/scons-2.5.0/scons-local-2.5.0/SCons/Node/FS.py21
2 files changed, 24 insertions, 12 deletions
diff --git a/SConstruct b/SConstruct
index 35c3ba191be..40043c5002c 100644
--- a/SConstruct
+++ b/SConstruct
@@ -3864,3 +3864,18 @@ env.Alias('cache-prune', cachePrune)
# because SCons wants it to be a particular object.
for i, s in enumerate(BUILD_TARGETS):
BUILD_TARGETS[i] = env.subst(s)
+
+def print_cache_stats():
+ from SCons.Node.FS import cache_hits
+ from SCons.Node.FS import cache_requests
+ if cache_requests == 0:
+ print('No cache requests were made.')
+ return
+
+ ratio = (float(cache_hits) / float(cache_requests)) * 100.0
+ print('Cache cache_hits: %d', cache_hits)
+ print('Cache cache_requests: %d', cache_requests)
+ print('Cache hit ratio: %d%%', ratio)
+
+import atexit
+atexit.register(print_cache_stats)
diff --git a/src/third_party/scons-2.5.0/scons-local-2.5.0/SCons/Node/FS.py b/src/third_party/scons-2.5.0/scons-local-2.5.0/SCons/Node/FS.py
index d71ded6549a..ab1bfa02588 100644
--- a/src/third_party/scons-2.5.0/scons-local-2.5.0/SCons/Node/FS.py
+++ b/src/third_party/scons-2.5.0/scons-local-2.5.0/SCons/Node/FS.py
@@ -2622,28 +2622,24 @@ class FileBuildInfo(SCons.Node.BuildInfoBase):
return '\n'.join(result)
+cache_hits = 0
+cache_requests = 0
+
+
def log_cache_rate(fn):
"""
Logs the cache hit ratio.
"""
- global requests
- global hits
- hits = 0
- requests = 0
def wrapper(self):
- global requests
- global hits
+ global cache_requests
+ global cache_hits
- requests += 1
+ cache_requests += 1
result = fn(self)
if result:
- hits += 1
- ratio = (float(hits) / float(requests)) * 100.0
+ cache_hits += 1
- print 'Cache hits: %d' % (hits)
- print 'Cache requests: %d' % (requests)
- print 'Cache hit ratio: %d%%' % (ratio)
return result
return wrapper
@@ -3009,6 +3005,7 @@ class File(Base):
return None
if not self.is_derived():
return None
+ print 'Should have requested...'
return self.get_build_env().get_CacheDir().retrieve(self)
def visited(self):