Update of /var/cvs/src/org/mmbase/cache
In directory james.mmbase.org:/tmp/cvs-serv16269
Modified Files:
ReleaseStrategy.java
Log Message:
evaluate methods can be called very very often. Every optimization is probably
welcome. Instantiating a new object, just to wrap in an substraction is
probably not a good idea then.
See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/cache
Index: ReleaseStrategy.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/cache/ReleaseStrategy.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- ReleaseStrategy.java 24 Feb 2007 21:57:51 -0000 1.23
+++ ReleaseStrategy.java 19 Aug 2008 17:20:23 -0000 1.24
@@ -27,7 +27,7 @@
*
* @author Ernst Bunders
* @since MMBase-1.8
- * @version $Id: ReleaseStrategy.java,v 1.23 2007/02/24 21:57:51 nklasens Exp $
+ * @version $Id: ReleaseStrategy.java,v 1.24 2008/08/19 17:20:23 michiel Exp $
*/
public abstract class ReleaseStrategy {
@@ -69,32 +69,32 @@
*
*/
public final StrategyResult evaluate(final NodeEvent event, final
SearchQuery query, final List<MMObjectNode> cachedResult) {
- final Timer timer = new Timer();
+ final long startTime = System.nanoTime();
if (isActive) {
boolean shouldRelease = doEvaluate(event, query, cachedResult);
totalEvaluated++;
if (!shouldRelease) totalPreserved++;
- long cost = timer.getNanoTime();
- totalEvaluationNanoTime+= cost;
+ long cost = System.nanoTime() - startTime;
+ totalEvaluationNanoTime += cost;
return new StrategyResult(shouldRelease, cost);
} else {
// if the cache is inactive it can not prevent the flush
- return new StrategyResult(true, timer.getTimeMillis());
+ return new StrategyResult(true, System.nanoTime() - startTime);
}
}
public final StrategyResult evaluate(RelationEvent event, SearchQuery
query, List<MMObjectNode> cachedResult) {
- Timer timer = new Timer();
+ final long startTime = System.nanoTime();
if (isActive) {
boolean shouldRelease = doEvaluate(event, query, cachedResult);
totalEvaluated++;
if (!shouldRelease) totalPreserved++;
- long cost = timer.getNanoTime();
+ long cost = System.nanoTime() - startTime;
totalEvaluationNanoTime += cost;
return new StrategyResult(shouldRelease, cost);
} else {
// if the cache is inactive it can not prevent the flush
- return new StrategyResult(true, timer.getTimeMillis());
+ return new StrategyResult(true, System.nanoTime() - startTime);
}
}
@@ -258,7 +258,7 @@
}
/**
- * The cost of a node event evaluation. XXX What is the cost?
+ * The cost of a node event evaluation. This is in nanoseconds.
*/
public long getCost() {
return cost;
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs