count object cache searches
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/lib/got_lib_object_cache.h b/lib/got_lib_object_cache.h
index 7c8c41b..d574268 100644
--- a/lib/got_lib_object_cache.h
+++ b/lib/got_lib_object_cache.h
@@ -33,6 +33,7 @@ struct got_object_cache {
enum got_object_cache_type type;
struct got_object_idcache *idcache;
size_t size;
+ int cache_searches;
int cache_hit;
int cache_miss;
int cache_evict;
diff --git a/lib/object_cache.c b/lib/object_cache.c
index 37d339c..8bba157 100644
--- a/lib/object_cache.c
+++ b/lib/object_cache.c
@@ -121,6 +121,7 @@ got_object_cache_get(struct got_object_cache *cache, struct got_object_id *id)
{
struct got_object_cache_entry *ce;
+ cache->cache_searches++;
ce = got_object_idcache_get(cache->idcache, id);
if (ce) {
cache->cache_hit++;
@@ -142,10 +143,11 @@ got_object_cache_get(struct got_object_cache *cache, struct got_object_id *id)
static void
print_cache_stats(struct got_object_cache *cache, const char *name)
{
- fprintf(stderr, "%s: %s cache: %d elements, %d hits, %d missed, "
- "%d evicted\n", getprogname(), name,
+ fprintf(stderr, "%s: %s cache: %d elements, %d searches, %d hits, "
+ "%d missed, %d evicted\n", getprogname(), name,
got_object_idcache_num_elements(cache->idcache),
- cache->cache_hit, cache->cache_miss, cache->cache_evict);
+ cache->cache_searches, cache->cache_hit,
+ cache->cache_miss, cache->cache_evict);
}
void check_refcount(struct got_object_id *id, void *data, void *arg)