Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ethlo committed Aug 27, 2019
1 parent 55eca16 commit 826cb52
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 44 deletions.
8 changes: 0 additions & 8 deletions src/main/java/com/ethlo/ascii/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,6 @@ else if (firstColumn && lastRow)
{
return theme.getLeftBottom();
}
else if (lastColumn && lastRow)
{
return theme.getRightBottom();
}
else if (lastColumn && firstRow)
{
return theme.getRightTop();
}
else if (firstColumn)
{
return theme.getLeftCross();
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/com/ethlo/time/Chronograph.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,6 @@ public Chronograph(final String name, final CaptureConfig captureConfig)
this.captureConfig = captureConfig;
}

public static void configure(TableTheme theme, OutputConfig outputConfig)
{
configure(theme);
configure(outputConfig);
}

public static void configure(final TableTheme theme)
{
Chronograph.theme = Objects.requireNonNull(theme, "theme cannot be null");
}

public static void configure(final OutputConfig outputConfig)
{
Chronograph.outputConfig = Objects.requireNonNull(outputConfig, "outputConfig cannot be null");
}

public static Chronograph create()
{
return new Chronograph("");
Expand Down
19 changes: 7 additions & 12 deletions src/main/java/com/ethlo/time/OutputConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public class OutputConfig
private boolean standardDeviation;
private boolean total;
private boolean percentage;
private Mode mode;
private boolean benchmarkMode;
private boolean formatting;
private PresentationMode mode = PresentationMode.DURATION;
private boolean benchmarkMode = false;
private boolean formatting = true;

public OutputConfig()
{
Expand Down Expand Up @@ -137,7 +137,7 @@ public boolean percentage()
return percentage;
}

public Mode getMode()
public PresentationMode getMode()
{
return mode;
}
Expand All @@ -152,7 +152,7 @@ public boolean formatting()
return formatting;
}

public OutputConfig mode(Mode mode)
public OutputConfig mode(PresentationMode mode)
{
return new OutputConfig(new Builder(this).mode(mode));
}
Expand Down Expand Up @@ -219,7 +219,7 @@ public OutputConfig formatting(final boolean b)

public static class Builder
{
private Mode mode;
private PresentationMode mode;
private String title;
private double[] percentiles;
private boolean median;
Expand Down Expand Up @@ -310,17 +310,12 @@ public Builder percentage(final boolean percentage)
return this;
}

public Builder mode(final Mode mode)
public Builder mode(final PresentationMode mode)
{
this.mode = mode;
return this;
}

public OutputConfig build()
{
return new OutputConfig(this);
}

public Builder benchmarkMode(final boolean b)
{
this.benchmarkMode = b;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* #L%
*/

public enum Mode
public enum PresentationMode
{
THROUGHPUT, DURATION;
}
4 changes: 2 additions & 2 deletions src/main/java/com/ethlo/time/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ private static void outputCell(final OutputConfig outputConfig, final TableRow r
final String str;
if (outputConfig.formatting())
{
str = outputConfig.getMode() == Mode.DURATION ? ReportUtil.humanReadable(duration) : ReportUtil.humanReadable(throughput);
str = outputConfig.getMode() == PresentationMode.DURATION ? ReportUtil.humanReadable(duration) : ReportUtil.humanReadable(throughput);
}
else
{
final NumberFormat nf = getRawNumberFormat();
str = outputConfig.getMode() == Mode.DURATION ? Long.toString(duration.toNanos()) : nf.format(throughput);
str = outputConfig.getMode() == PresentationMode.DURATION ? Long.toString(duration.toNanos()) : nf.format(throughput);
}
row.append(new TableCell(str, false, true));
}
Expand Down
9 changes: 4 additions & 5 deletions src/test/java/com/ethlo/util/ListPerformanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@
import com.ethlo.time.CaptureConfig;
import com.ethlo.time.Chronograph;
import com.ethlo.time.ChronographData;
import com.ethlo.time.Mode;
import com.ethlo.time.PresentationMode;
import com.ethlo.time.OutputConfig;
import com.ethlo.time.Report;
import com.ethlo.time.TaskPerformanceStatistics;

public class ListPerformanceTest
{
Expand Down Expand Up @@ -73,7 +72,7 @@ public void performanceTestLargeArrayList()
c.timed("sort", () -> list.sort(Comparator.naturalOrder()));
}

logger.info(c.prettyPrint("ArrayList"));
logger.info(c.prettyPrint("ArrayList"), new OutputConfig().mode(PresentationMode.THROUGHPUT));
assertThat(true).isTrue();
}

Expand Down Expand Up @@ -107,7 +106,7 @@ public void rateLimitingTest()
c.timed("Adding", () -> list.add(randomNano()));
}

System.out.println(Report.prettyPrint(c.getTaskData(), OutputConfig.DEFAULT.mode(Mode.THROUGHPUT).formatting(false).percentiles(90, 95, 99, 99.9), TableTheme.TSV));
System.out.println(Report.prettyPrint(c.getTaskData(), OutputConfig.DEFAULT.mode(PresentationMode.THROUGHPUT).formatting(false).percentiles(90, 95, 99, 99.9), TableTheme.TSV));
}

private void doAdd(final IndexedCollection<Long> list, final long value)
Expand Down Expand Up @@ -169,7 +168,7 @@ public void testCombinedPerformanceTable()
final ChronographData combined = ChronographData.combine("Combined", Arrays.asList(a, b));

System.out.println(Report.prettyPrint(combined,
OutputConfig.EXTENDED.mode(Mode.THROUGHPUT).benchmarkMode(true),
OutputConfig.EXTENDED.mode(PresentationMode.THROUGHPUT).benchmarkMode(true),
TableTheme.RED_HERRING));

assertThat(true).isTrue();
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/com/ethlo/util/LongListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,11 @@ public void iterator()
}
assertThat(count).isEqualTo(10);
}

@Test
public void size()
{
final LongList l = createList(10, true);
assertThat(l.size()).isEqualTo(10);
}
}

0 comments on commit 826cb52

Please sign in to comment.