Author: mircea.markus
Date: 2009-10-21 05:54:32 -0400 (Wed, 21 Oct 2009)
New Revision: 8265
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java
Log:
more accurate progress logging
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java
===================================================================
---
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java 2009-10-21
09:42:24 UTC (rev 8264)
+++
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java 2009-10-21
09:54:32 UTC (rev 8265)
@@ -91,7 +91,6 @@
AtomicLong durationNanos = new AtomicLong(0);
for (int i = 0; i < numberOfRequests; i++)
{
- logRunCount(i);
randomAction = r.nextInt(100);
randomAttribute = r.nextInt(numberOfAttributes - 1);
byte[] buf;
@@ -102,13 +101,13 @@
if (randomAction < readPercentage)
{
// read
- ex.execute(new ReadTask(path, durationNanos, sessionEntry));
+ ex.execute(new ReadTask(path, durationNanos, sessionEntry, i));
reads++;
}
else
{
// write
- ex.execute(new WriteTask(path, durationNanos, sessionEntry));
+ ex.execute(new WriteTask(path, durationNanos, sessionEntry, i));
writes++;
}
}
@@ -242,20 +241,22 @@
List<String> path;
AtomicLong durationNanos;
Object sessionEntry;
+ int taskNumber;
- protected Task(List<String> path, AtomicLong durationNanos, Object
sessionEntry)
+ protected Task(List<String> path, AtomicLong durationNanos, Object
sessionEntry, int taskNumber)
{
this.path = path;
this.durationNanos = durationNanos;
this.sessionEntry = sessionEntry;
+ this.taskNumber = taskNumber;
}
}
private class WriteTask extends Task
{
- protected WriteTask(List<String> path, AtomicLong durationNanos, Object
sessionEntry)
+ protected WriteTask(List<String> path, AtomicLong durationNanos, Object
sessionEntry, int i)
{
- super(path, durationNanos, sessionEntry);
+ super(path, durationNanos, sessionEntry, i);
}
public void run()
@@ -271,15 +272,17 @@
catch (Throwable e)
{
log.warn("Error appeared whilst writing to cache:" +
e.getMessage(), e);
+ } finally {
+ logRunCount(taskNumber);
}
}
}
private class ReadTask extends Task
{
- protected ReadTask(List<String> path, AtomicLong durationNanos, Object
sessionEntry)
+ protected ReadTask(List<String> path, AtomicLong durationNanos, Object
sessionEntry, int i)
{
- super(path, durationNanos, sessionEntry);
+ super(path, durationNanos, sessionEntry, i);
}
public void run()
@@ -294,6 +297,8 @@
catch (Throwable e)
{
log.warn("Error appeared whilst reading from cache:" +
e.getMessage(), e);
+ } finally {
+ logRunCount(taskNumber);
}
}
}