Commit 221e79cdddc404707056ccd771cc9f38aea3f09c

Stefan Sperling 2018-09-16T19:30:04

count object cache searches

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)