package com.github.sbugat.nqueens;

public abstract class GenericInstrumentedNQueensSolver extends GenericNQueensSolver {

	/** Number of queen placements counter. */
	protected long queenPlacementsCount;

	/** Number of square reads counter. */
	protected long squareReadsCount;

	/** Number of tests done counter. */
	protected long squareWritesCount;

	/** Number of explicittests done counter. */
	protected long explicitTestsCount;

	/** Number of implicit tests done counter (loop). */
	protected long implicitTestsCount;

	/** Number of methods calls counter. */
	protected long methodCallsCount;

	protected GenericInstrumentedNQueensSolver(final int chessboardSizeArg, final boolean printSolutionArg) {

		super(chessboardSizeArg, printSolutionArg);
	}

	@Override
	public void reset() {

		super.reset();

		// Reinitialize generic instrumentations
		queenPlacementsCount = 0;
		squareReadsCount = 0;
		squareWritesCount = 0;
		explicitTestsCount = 0;
		implicitTestsCount = 0;
		methodCallsCount = 0;
	}

	@Override
	public String toString() {

		final StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append("queen placements count:");
		stringBuilder.append(queenPlacementsCount);

		stringBuilder.append(System.lineSeparator());
		stringBuilder.append("square reads count:");
		stringBuilder.append(squareReadsCount);

		stringBuilder.append(System.lineSeparator());
		stringBuilder.append("square writes count:");
		stringBuilder.append(squareWritesCount);

		stringBuilder.append(System.lineSeparator());
		stringBuilder.append(System.lineSeparator());
		stringBuilder.append("explicit tests count:");
		stringBuilder.append(explicitTestsCount);
		stringBuilder.append(System.lineSeparator());
		stringBuilder.append("implicit tests count:");
		stringBuilder.append(implicitTestsCount);
		stringBuilder.append(System.lineSeparator());
		stringBuilder.append("total tests count:");
		stringBuilder.append(explicitTestsCount + implicitTestsCount);

		stringBuilder.append(System.lineSeparator());
		stringBuilder.append(System.lineSeparator());
		stringBuilder.append("method calls count:");
		stringBuilder.append(methodCallsCount);

		return stringBuilder.toString();
	}

	public final String toJavaScriptData(final String dataPrefix) {

		final StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append(" \"" + dataPrefix + "queenPlacements\": " + Math.log(queenPlacementsCount) + ", ");
		stringBuilder.append(" \"" + dataPrefix + "methodCalls\": " + Math.log(methodCallsCount) + ", ");
		stringBuilder.append(" \"" + dataPrefix + "squareReads\": " + Math.log(squareReadsCount) + ", ");
		stringBuilder.append(" \"" + dataPrefix + "explicitTests\": " + Math.log(explicitTestsCount) + ", ");
		stringBuilder.append(" \"" + dataPrefix + "implicitTests\": " + Math.log(implicitTestsCount));

		return stringBuilder.toString();
	}

	public abstract String getName();
}

@@ -2383,32 +2383,501 @@
 lacements%5C%22: %22 +
+ queenPlacementsCount + %22, %22);%0A%09%09stringBuilder.append(%22 %5C%22%22 + dataPrefix + %22methodCalls%5C%22: %22 + methodCallsCount + %22, %22);%0A%09%09stringBuilder.append(%22 %5C%22%22 + dataPrefix + %22squareReads%5C%22: %22 + squareReadsCount + %22, %22);%0A%09%09stringBuilder.append(%22 %5C%22%22 + dataPrefix + %22explicitTests%5C%22: %22 + explicitTestsCount + %22, %22);%0A%09%09stringBuilder.append(%22 %5C%22%22 + dataPrefix + %22implicitTests%5C%22: %22 + implicitTestsCount + %22, %22);%0A%09%09stringBuilder.append(%22 %5C%22%22 + dataPrefix + %22queenPlacementsLog%5C%22: %22 +
  Math.log(queenP
@@ -2949,32 +2949,35 @@
 x + %22methodCalls
+Log
 %5C%22: %22 + Math.log
@@ -3052,32 +3052,35 @@
 x + %22squareReads
+Log
 %5C%22: %22 + Math.log
@@ -3157,32 +3157,35 @@
 + %22explicitTests
+Log
 %5C%22: %22 + Math.log
@@ -3264,32 +3264,35 @@
 + %22implicitTests
+Log
 %5C%22: %22 + Math.log

Add log collected data