Skip to content

Commit

Permalink
Improve tx tracking in checkpoint stress test
Browse files Browse the repository at this point in the history
Transaction is considered committed only after it is closed.
Throughput is measured in 'tx/s' instead of 'tx/ms' because this produces a
more pleasant number.
All output goes to System.out so it is not mixed in the build log.
  • Loading branch information
lutovich committed May 31, 2016
1 parent b2762ea commit 02c1ef0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Expand Up @@ -22,6 +22,7 @@
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.neo4j.kernel.stresstests.transaction.checkpoint.workload.Workload;

Expand All @@ -32,9 +33,10 @@ public class TransactionThroughputChecker implements Workload.TransactionThrough
private final List<Double> reports = new ArrayList<>();

@Override
public void report( long transactions, long elapsedTime)
public void report( long transactions, long timeSlotMillis )
{
reports.add( ((double) transactions / (double) elapsedTime) );
long elapsedSeconds = TimeUnit.MILLISECONDS.toSeconds( timeSlotMillis );
reports.add( ((double) transactions / (double) elapsedSeconds) );
}

public void assertThroughput( PrintStream out )
Expand All @@ -45,7 +47,7 @@ public void assertThroughput( PrintStream out )
return;
}

out.println( "Throughput reports (tx/ms):" );
out.println( "Throughput reports (tx/s):" );
double sum = 0;
for ( double report : reports )
{
Expand All @@ -55,7 +57,7 @@ public void assertThroughput( PrintStream out )
out.println();

double average = sum / (double) reports.size();
out.println( "Average throughput (tx/ms): " + average );
out.println( "Average throughput (tx/s): " + average );

double powerSum = 0.0;
for ( double report : reports )
Expand All @@ -64,9 +66,9 @@ public void assertThroughput( PrintStream out )
}

double stdDeviation = Math.sqrt( powerSum / (double) reports.size() );
out.println( "Standard deviation (tx/ms): " + stdDeviation );
out.println( "Standard deviation (tx/s): " + stdDeviation );
double twoStdDeviations = stdDeviation * 2.0;
out.println( "Two standard deviations (tx/ms): " + twoStdDeviations );
out.println( "Two standard deviations (tx/s): " + twoStdDeviations );

int inOneStdDeviationRange = 0;
int inTwoStdDeviationRange = 0;
Expand All @@ -79,12 +81,12 @@ public void assertThroughput( PrintStream out )
}
else if ( Math.abs( average - report ) <= twoStdDeviations )
{
System.err.println( "Outside _one_ std deviation range: " + report );
out.println( "Outside _one_ std deviation range: " + report );
inTwoStdDeviationRange++;
}
else
{
System.err.println( "Outside _two_ std deviation range: " + report );
out.println( "Outside _two_ std deviation range: " + report );
}
}

Expand Down
Expand Up @@ -58,7 +58,6 @@ public void run()
randomMutation.perform();
}
tx.success();
monitor.transactionCompleted();
}
catch ( DeadlockDetectedException ignore )
{
Expand All @@ -69,6 +68,8 @@ public void run()
// ignore and go on
e.printStackTrace();
}

monitor.transactionCompleted();
}
while ( !monitor.stop() );

Expand Down

0 comments on commit 02c1ef0

Please sign in to comment.