// Path: benchmarks-api/src/main/java/uk/co/real_logic/benchmarks/remote/PersistedHistogram.java
// static final String AGGREGATE_FILE_SUFFIX = "-combined" + FILE_EXTENSION;
// 
// Path: benchmarks-api/src/main/java/uk/co/real_logic/benchmarks/remote/PersistedHistogram.java
// static final String REPORT_FILE_SUFFIX = "-report.hgrm";


import static uk.co.real_logic.benchmarks.remote.PersistedHistogram.AGGREGATE_FILE_SUFFIX;
import static uk.co.real_logic.benchmarks.remote.PersistedHistogram.REPORT_FILE_SUFFIX;
import org.HdrHistogram.Histogram;
import org.HdrHistogram.HistogramLogReader;
import org.HdrHistogram.HistogramLogWriter;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import java.io.*;
import java.nio.file.Path;
import static java.nio.file.Files.*;
import static java.nio.file.StandardOpenOption.CREATE_NEW;
import static java.util.Arrays.sort;
import static org.junit.jupiter.api.Assertions.*;
        aggregator.run();

        assertArrayEquals(new File[]{ otherFile.toFile() }, tempDir.toFile().listFiles());
    }

    @Test
    void multipleHistogramFiles() throws IOException
    {
        saveToDisc("my-5.hdr", createHistogram(10, 25, 100, 555, 777, 999));
        saveToDisc("my-0.hdr", createHistogram(2, 4, 555555, 1232343));
        saveToDisc("my-combined.hdr", createHistogram(3, 4, 11, 1, 1, 22));
        saveToDisc("other-78.hdr", createHistogram(1, 45, 200));
        write(tempDir.resolve("other-report.hgrm"), new byte[]{ 0, -128, 127 }, CREATE_NEW);
        saveToDisc("hidden-4.ccc", createHistogram(0, 0, 1, 2, 3, 4, 5, 6));
        saveToDisc("hidden-6.ccc", createHistogram(0, 0, 6, 6, 0));

        final double reportOutputScalingRatio = 250.0;
        final ResultsAggregator aggregator = new ResultsAggregator(tempDir, reportOutputScalingRatio);

        aggregator.run();

        final String[] aggregateFiles = tempDir.toFile().list((dir, name) -> name.endsWith(AGGREGATE_FILE_SUFFIX));
        assertNotNull(aggregateFiles);
        sort(aggregateFiles);
        assertArrayEquals(new String[]{ "my-combined.hdr", "other-combined.hdr" }, aggregateFiles);
        final Histogram myAggregate = createHistogram(2, 25, 100, 555, 777, 999, 555555, 1232343);
        assertEquals(myAggregate, loadFromDisc("my-combined.hdr"));
        final Histogram otherAggregate = createHistogram(1, 45, 200);
        assertEquals(otherAggregate, loadFromDisc("other-combined.hdr"));

// Path: benchmarks-api/src/main/java/uk/co/real_logic/benchmarks/remote/PersistedHistogram.java
// static final String AGGREGATE_FILE_SUFFIX = "-combined" + FILE_EXTENSION;
// 
// Path: benchmarks-api/src/main/java/uk/co/real_logic/benchmarks/remote/PersistedHistogram.java
// static final String REPORT_FILE_SUFFIX = "-report.hgrm";


// Path: benchmarks-api/src/test/java/uk/co/real_logic/benchmarks/remote/ResultsAggregatorTest.java
import static uk.co.real_logic.benchmarks.remote.PersistedHistogram.AGGREGATE_FILE_SUFFIX;
import static uk.co.real_logic.benchmarks.remote.PersistedHistogram.REPORT_FILE_SUFFIX;
import org.HdrHistogram.Histogram;
import org.HdrHistogram.HistogramLogReader;
import org.HdrHistogram.HistogramLogWriter;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import java.io.*;
import java.nio.file.Path;
import static java.nio.file.Files.*;
import static java.nio.file.StandardOpenOption.CREATE_NEW;
import static java.util.Arrays.sort;
import static org.junit.jupiter.api.Assertions.*;

        aggregator.run();

        assertArrayEquals(new File[]{ otherFile.toFile() }, tempDir.toFile().listFiles());
    }

    @Test
    void multipleHistogramFiles() throws IOException
    {
        saveToDisc("my-5.hdr", createHistogram(10, 25, 100, 555, 777, 999));
        saveToDisc("my-0.hdr", createHistogram(2, 4, 555555, 1232343));
        saveToDisc("my-combined.hdr", createHistogram(3, 4, 11, 1, 1, 22));
        saveToDisc("other-78.hdr", createHistogram(1, 45, 200));
        write(tempDir.resolve("other-report.hgrm"), new byte[]{ 0, -128, 127 }, CREATE_NEW);
        saveToDisc("hidden-4.ccc", createHistogram(0, 0, 1, 2, 3, 4, 5, 6));
        saveToDisc("hidden-6.ccc", createHistogram(0, 0, 6, 6, 0));

        final double reportOutputScalingRatio = 250.0;
        final ResultsAggregator aggregator = new ResultsAggregator(tempDir, reportOutputScalingRatio);

        aggregator.run();

        final String[] aggregateFiles = tempDir.toFile().list((dir, name) -> name.endsWith(AGGREGATE_FILE_SUFFIX));
        assertNotNull(aggregateFiles);
        sort(aggregateFiles);
        assertArrayEquals(new String[]{ "my-combined.hdr", "other-combined.hdr" }, aggregateFiles);
        final Histogram myAggregate = createHistogram(2, 25, 100, 555, 777, 999, 555555, 1232343);
        assertEquals(myAggregate, loadFromDisc("my-combined.hdr"));
        final Histogram otherAggregate = createHistogram(1, 45, 200);
        assertEquals(otherAggregate, loadFromDisc("other-combined.hdr"));

        final String[] reportFiles = tempDir.toFile().list((dir, name) -> name.endsWith(REPORT_FILE_SUFFIX));