/*
 * Copyright (c) 2012-2013 by Jens V. Fischer, Zuse Institute Berlin
 *
 *
 * Licensed under the BSD License, see LICENSE file for details.
 *
 */

package org.xtreemfs.sandbox.benchmark;

/**
 * Result objects for {@link Benchmark}.
 * 
 * @author jensvfischer
 */
public class BenchmarkResult {

    final static int MiB_IN_BYTES = 1024 * 1024;
    final static int GiB_IN_BYTES = 1024 * 1024 * 1024;

    BenchmarkType    benchmarkType;
    int              numberOfReadersOrWriters;
    double           timeInSec;
    double           speedInMiBProSec;
    long             dataWrittenInBytes;
    long             threadID;
    long             byteCount;

    public BenchmarkResult(double timeInSec, double speedInMiBProSec, long dataWrittenInBytes, long threadID,
            long byteCount) {
        this.timeInSec = timeInSec;
        this.speedInMiBProSec = speedInMiBProSec;
        this.dataWrittenInBytes = dataWrittenInBytes;
        this.threadID = threadID;
        this.byteCount = byteCount;
    }

    @Override
    public String toString() {

        String dataWritten = dataWrittenInBytes >= GiB_IN_BYTES ? dataWrittenInBytes / GiB_IN_BYTES + " GiB ["
                : dataWrittenInBytes / MiB_IN_BYTES + " MiB [";
        String readersOrWriters;

        if (benchmarkType == BenchmarkType.SEQUENTIAL_SINGLE_WRITE
                || benchmarkType == BenchmarkType.SEQUENTIAL_MULTI_WRITE) {
            readersOrWriters = "\tNumber of Writers: " + numberOfReadersOrWriters + "\n";
        } else if (benchmarkType == BenchmarkType.SEQUENTIAL_SINGLE_READ
                || benchmarkType == BenchmarkType.SEQUENTIAL_MULTI_READ) {
            readersOrWriters = "\tNumber of Readers: " + numberOfReadersOrWriters + "\n";
        } else {
            readersOrWriters = "\tNumber of Readers/Writers: " + numberOfReadersOrWriters + "\n";
        }

        return "{\n\tBenchmarkType: " + benchmarkType + "\n" + readersOrWriters + "\tThreadID: " + threadID + "\n"
                + "\tTime: " + timeInSec + " Sec\n" + "\tSpeed: " + speedInMiBProSec + " MiB/s\n" + "\tData written: "
                + dataWritten + dataWrittenInBytes + " Bytes]\n" + "\tByteCount: " + byteCount + " Bytes\n" + "}";
    }


}

@@ -1025,16 +1025,18 @@
    @
-Override
+Deprecated
 %0A   
@@ -1058,16 +1058,17 @@
 toString
+1
 () %7B%0A%0A  
@@ -2227,11 +2227,193 @@
 %0A    %7D%0A%0A
+    @Override%0A    public String toString()%7B%0A        return benchmarkType+%22;%22+numberOfReadersOrWriters+%22;%22+timeInSec+%22;%22+speedInMiBProSec+%22;%22+dataWrittenInBytes+%22;%22+byteCount;%0A    %7D%0A%0A
 %0A%7D%0A

Change output to csv