1.1 --- a/mdr/src/org/netbeans/mdr/persistence/btreeimpl/btreestorage/MDRCache.java Sun Oct 10 19:01:21 2004 +0000
1.2 +++ b/mdr/src/org/netbeans/mdr/persistence/btreeimpl/btreestorage/MDRCache.java Mon Oct 11 17:43:38 2004 +0000
1.3 @@ -70,6 +70,9 @@
1.4 private static final int threshhold = Integer.getInteger(
1.5 "org.netbeans.mdr.persistence.btreeimpl.btreestorage.MDRCache.threshhold",
1.6 BtreeDatabase.MDR_CACHE_THRESHHOLD).intValue() * 2;
1.7 +
1.8 + private static final boolean CACHE_DEBUG = Boolean.getBoolean("perf.mdr.MDRCache");
1.9 +
1.10 private static int size = 0;
1.11
1.12 private int localThreshhold;
1.13 @@ -77,9 +80,9 @@
1.14
1.15
1.16 /* caching statistics */
1.17 - int hits;
1.18 - int misses;
1.19 - int maxSize;
1.20 + private static int hits;
1.21 + private static int misses;
1.22 + //int maxSize;
1.23
1.24 /** Create the cache
1.25 * @param size how many objects to cache in memory
1.26 @@ -198,10 +201,10 @@
1.27 hashOnId.put(m, o);
1.28 }
1.29 makeHardRef(m, o);
1.30 - int curSize = hashOnId.size();
1.31 - if (curSize > maxSize) {
1.32 - maxSize = curSize;
1.33 - }
1.34 +// int curSize = hashOnId.size();
1.35 +// if (curSize > maxSize) {
1.36 +// maxSize = curSize;
1.37 +// }
1.38 }
1.39
1.40 /** get an object from the cache
1.41 @@ -211,9 +214,19 @@
1.42 Object o = hashOnId.get(m);
1.43 if (o != null) {
1.44 makeHardRef(m, o);
1.45 - hits++;
1.46 - } else {
1.47 - misses++;
1.48 + }
1.49 +
1.50 + if (CACHE_DEBUG) {
1.51 + synchronized (MDRCache.class) {
1.52 + if (o != null) {
1.53 + hits++;
1.54 + } else {
1.55 + misses++;
1.56 + }
1.57 + if ((hits + misses) % 20000 == 0) {
1.58 + showStats(System.err);
1.59 + }
1.60 + }
1.61 }
1.62 return o;
1.63 }
1.64 @@ -430,9 +443,9 @@
1.65 */
1.66 public void showStats(PrintWriter strm) {
1.67 strm.println(
1.68 - "Cache hits: " + hits + " misses: " + misses +
1.69 + "MDRCache hits: " + hits + " misses: " + misses +
1.70 " hit rate: " + 100. * (float)hits / (float)(hits + misses));
1.71 - strm.println("Maximum size: " + maxSize);
1.72 + //strm.println("Maximum size: " + maxSize);
1.73 strm.flush();
1.74 }
1.75