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\": " + queenPlacementsCount + ", ");
		stringBuilder.append(" \"" + dataPrefix + "methodCalls\": " + methodCallsCount + ", ");
		stringBuilder.append(" \"" + dataPrefix + "squareReads\": " + squareReadsCount + ", ");
		stringBuilder.append(" \"" + dataPrefix + "explicitTests\": " + explicitTestsCount + ", ");
		stringBuilder.append(" \"" + dataPrefix + "implicitTests\": " + implicitTestsCount);

		return stringBuilder.toString();
	}

	public abstract String getName();
}

@@ -2392,16 +2392,25 @@
 %5C%22: %22 + 
+Math.log(
 queenPla
@@ -2417,24 +2417,25 @@
 cementsCount
+)
  + %22, %22);%0A%09%09
@@ -2496,16 +2496,25 @@
 %5C%22: %22 + 
+Math.log(
 methodCa
@@ -2517,24 +2517,25 @@
 odCallsCount
+)
  + %22, %22);%0A%09%09
@@ -2596,16 +2596,25 @@
 %5C%22: %22 + 
+Math.log(
 squareRe
@@ -2617,24 +2617,25 @@
 reReadsCount
+)
  + %22, %22);%0A%09%09
@@ -2698,16 +2698,25 @@
 %5C%22: %22 + 
+Math.log(
 explicit
@@ -2725,16 +2725,17 @@
 stsCount
+)
  + %22, %22)
@@ -2802,16 +2802,25 @@
 %5C%22: %22 + 
+Math.log(
 implicit
@@ -2826,24 +2826,25 @@
 tTestsCount)
+)
 ;%0A%0A%09%09return 

Change collected Data to logarithm