diff options
| author | ruki <[email protected]> | 2022-05-20 22:35:12 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-20 22:35:12 +0800 |
| commit | e0c42d493f49eb2ede38daeb078dddd6e6f581ce (patch) | |
| tree | 58a1572b8556c13a61f6b7d522c923fa6a9c3b1f /xmake/modules/private/cache/build_cache.lua | |
| parent | 654a849bbaba584a1aeb61a4afaea879e191d4da (diff) | |
dump cache stats
Diffstat (limited to 'xmake/modules/private/cache/build_cache.lua')
| -rw-r--r-- | xmake/modules/private/cache/build_cache.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/xmake/modules/private/cache/build_cache.lua b/xmake/modules/private/cache/build_cache.lua index 16655a632..3da7e35f0 100644 --- a/xmake/modules/private/cache/build_cache.lua +++ b/xmake/modules/private/cache/build_cache.lua @@ -85,6 +85,21 @@ function hitrate() return 0 end + +-- dump stats +function dump_stats() + local hit_count = (_g.hit_count or 0) + local total_count = (_g.total_count or 0) + local files_count = (_g.files_count or 0) + vprint("") + vprint("build cache stats:") + vprint("cache directory: %s", rootdir()) + vprint("cache hit rate: %d%%", hitrate()) + vprint("cache hit: %d", hit_count) + vprint("cache miss: %d", total_count - hit_count) + vprint("files in cache: %d", files_count) +end + -- get object file function get(cachekey) _g.total_count = (_g.total_count or 0) + 1 @@ -99,6 +114,7 @@ end function put(cachekey, objectfile) local objectfile_cached = path.join(rootdir(), cachekey:sub(1, 2):lower(), cachekey) os.cp(objectfile, objectfile_cached) + _g.files_count = (_g.files_count or 0) + 1 end -- build with cache |
