[poppler] test: read-cache.c, 1.2, 1.3 test-poppler.c, 1.7, 1.8 read-cache.h, NONE, 1.1

Jeff Muizelaar jrmuizel at kemper.freedesktop.org
Wed Oct 25 12:48:15 PDT 2006


Update of /cvs/poppler/test
In directory kemper:/tmp/cvs-serv25466

Modified Files:
	read-cache.c test-poppler.c 
Added Files:
	read-cache.h 
Log Message:
Add read-cache.h (I guess this thing wasn't building....)
Also report cache statistics and fix a bug that would cause the
cache reader to get out of sync if an entry was missing.


Index: read-cache.c
===================================================================
RCS file: /cvs/poppler/test/read-cache.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- read-cache.c	7 Sep 2006 03:19:35 -0000	1.2
+++ read-cache.c	25 Oct 2006 19:48:13 -0000	1.3
@@ -53,6 +53,14 @@
   printf("\n");
 }
 
+static int cache_misses;
+static int cache_hits;
+
+void cache_stats_print(void)
+{
+  printf("cache: %d of %d hits\n", cache_hits, cache_misses + cache_hits);
+}
+
 int cache_compare(const char *path, const unsigned char *buffer, unsigned int length)
 {
   char *path_copy = strdup(path);
@@ -76,8 +84,6 @@
       //printf("match %d\n", match);
       break;
     } else if (result < 0) {
-      //printf("moving to next entry: %s vs. %s did not match\n", name, current_cache_entry);
-      current_cache_entry += cache_length + 1 + SHA_DIGEST_LENGTH;
       break;
     } else {
       //printf("trying next entry: %s vs. %s did not match\n", name, current_cache_entry);
@@ -86,5 +92,10 @@
   }
   free(path_copy);
 
+  if (match)
+    cache_hits++;
+  else
+    cache_misses++;
+
   return match;
 }

Index: test-poppler.c
===================================================================
RCS file: /cvs/poppler/test/test-poppler.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- test-poppler.c	7 Sep 2006 03:20:42 -0000	1.7
+++ test-poppler.c	25 Oct 2006 19:48:13 -0000	1.8
@@ -178,6 +178,7 @@
 
   total_secs = (end.tv_sec - start.tv_sec);
   printf("tests took %dmin %dsec\n", total_secs / 60, total_secs % 60);
+  cache_stats_print();
   return 0;
 }
 

--- NEW FILE: read-cache.h ---
void cache_init(const char *path);
int cache_compare(const char *path, const unsigned char *buffer, unsigned int length);
FILE *cache_open(const char *path, const char *mode);
void cache_stats_print(void);



More information about the poppler mailing list