From: gmungoc Date: Mon, 13 Nov 2017 16:23:12 +0000 (+0000) Subject: JAL-2662 tweak README, format code X-Git-Tag: Release_2_10_3b1~36 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6dc86748c90f09948e6a6850e2542e55c0464683;p=jalview.git JAL-2662 tweak README, format code --- diff --git a/benchmarking/README b/benchmarking/README index 60b94a9..fac0bf6 100644 --- a/benchmarking/README +++ b/benchmarking/README @@ -1,11 +1,13 @@ To set up benchmarking: -1. In the jalview directory run +You will need to install Maven: https://maven.apache.org/install.html + +1. Run the makedist target of build.xml in Eclipse, or in the jalview directory run ant makedist This builds a jalview.jar file and puts it into dist/ -2. Make a lib directory in benchmarking/ if not already present. +2. Make a lib directory in benchmarking/ if not already present and cd into this directory. 3. Purge any previous maven dependencies: mvn dependency:purge-local-repository -DactTransitively=false -DreResolve=false diff --git a/benchmarking/src/main/java/org/jalview/HiddenColumnsBenchmark.java b/benchmarking/src/main/java/org/jalview/HiddenColumnsBenchmark.java index eb35e3b..d3c67d7 100644 --- a/benchmarking/src/main/java/org/jalview/HiddenColumnsBenchmark.java +++ b/benchmarking/src/main/java/org/jalview/HiddenColumnsBenchmark.java @@ -47,126 +47,128 @@ import jalview.datamodel.HiddenColumns; @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @Fork(1) public class HiddenColumnsBenchmark -{ - /* - * State with multiple hidden columns and a start position set - */ - @State(Scope.Thread) - public static class HiddenColsAndStartState - { - @Param({"300", "10000", "100000"}) - public int maxcols; - - @Param({"1", "50", "90"}) - public int startpcnt; // position as percentage of maxcols - - @Param({"1","15","100"}) - public int hide; - - HiddenColumns h = new HiddenColumns(); - Random rand = new Random(); - - public int hiddenColumn; - public int visibleColumn; - - @Setup - public void setup() - { - rand.setSeed(1234); - int lastcol = 0; - while (lastcol < maxcols) - { - int count = rand.nextInt(100); - lastcol += count; - h.hideColumns(lastcol, lastcol+hide); - lastcol+=hide; - } - - // make sure column at start is hidden - hiddenColumn = (int)(maxcols * startpcnt/100.0); - h.hideColumns(hiddenColumn, hiddenColumn); - - // and column after start is visible - ColumnSelection sel = new ColumnSelection(); - h.revealHiddenColumns(hiddenColumn+hide, sel); - visibleColumn = hiddenColumn+hide; - - System.out.println("Maxcols: " + maxcols + " HiddenCol: " + hiddenColumn + " Hide: " + hide); - System.out.println("Number of hidden columns: " + h.getSize()); - } - } - - /* Convention: functions in alphabetical order */ - - @Benchmark - @BenchmarkMode({Mode.Throughput}) - public int benchAdjustForHiddenColumns(HiddenColsAndStartState tstate) - { - return tstate.h.adjustForHiddenColumns(tstate.visibleColumn); - } - - @Benchmark - @BenchmarkMode({Mode.Throughput}) - public int benchFindColumnPosition(HiddenColsAndStartState tstate) - { - return tstate.h.findColumnPosition(tstate.visibleColumn); - } - - @Benchmark - @BenchmarkMode({Mode.Throughput}) - public List benchFindHiddenRegionPositions(HiddenColsAndStartState tstate) - { - return tstate.h.findHiddenRegionPositions(); - } - - @Benchmark - @BenchmarkMode({Mode.Throughput}) - public ArrayList benchGetHiddenColumnsCopy(HiddenColsAndStartState tstate) - { - return tstate.h.getHiddenColumnsCopy(); - } - - - @Benchmark - @BenchmarkMode({Mode.Throughput}) - public int benchGetSize(HiddenColsAndStartState tstate) - { - return tstate.h.getSize(); - } +{ + /* + * State with multiple hidden columns and a start position set + */ + @State(Scope.Thread) + public static class HiddenColsAndStartState + { + @Param({ "300", "10000", "100000" }) + public int maxcols; - @Benchmark - @BenchmarkMode({Mode.Throughput}) - public HiddenColumns benchHideCols(HiddenColsAndStartState tstate) - { - tstate.h.hideColumns(tstate.visibleColumn, - tstate.visibleColumn+2000); - return tstate.h; - } - - @Benchmark - @BenchmarkMode({Mode.Throughput}) - public boolean benchIsVisible(HiddenColsAndStartState tstate) - { - return tstate.h.isVisible(tstate.hiddenColumn); - } - - @Benchmark - @BenchmarkMode({Mode.Throughput}) - public HiddenColumns benchReveal(HiddenColsAndStartState tstate) - { - ColumnSelection sel = new ColumnSelection(); - tstate.h.revealHiddenColumns(tstate.hiddenColumn, sel); - return tstate.h; - } - - @Benchmark - @BenchmarkMode({Mode.Throughput}) - public HiddenColumns benchRevealAll(HiddenColsAndStartState tstate) + @Param({ "1", "50", "90" }) + public int startpcnt; // position as percentage of maxcols + + @Param({ "1", "15", "100" }) + public int hide; + + HiddenColumns h = new HiddenColumns(); + + Random rand = new Random(); + + public int hiddenColumn; + + public int visibleColumn; + + @Setup + public void setup() { - ColumnSelection sel = new ColumnSelection(); - tstate.h.revealAllHiddenColumns(sel); - return tstate.h; + rand.setSeed(1234); + int lastcol = 0; + while (lastcol < maxcols) + { + int count = rand.nextInt(100); + lastcol += count; + h.hideColumns(lastcol, lastcol + hide); + lastcol += hide; + } + + // make sure column at start is hidden + hiddenColumn = (int) (maxcols * startpcnt / 100.0); + h.hideColumns(hiddenColumn, hiddenColumn); + + // and column after start is visible + ColumnSelection sel = new ColumnSelection(); + h.revealHiddenColumns(hiddenColumn + hide, sel); + visibleColumn = hiddenColumn + hide; + + System.out.println("Maxcols: " + maxcols + " HiddenCol: " + + hiddenColumn + " Hide: " + hide); + System.out.println("Number of hidden columns: " + h.getSize()); } - - + } + + /* Convention: functions in alphabetical order */ + + @Benchmark + @BenchmarkMode({ Mode.Throughput }) + public int benchAdjustForHiddenColumns(HiddenColsAndStartState tstate) + { + return tstate.h.adjustForHiddenColumns(tstate.visibleColumn); + } + + @Benchmark + @BenchmarkMode({ Mode.Throughput }) + public int benchFindColumnPosition(HiddenColsAndStartState tstate) + { + return tstate.h.findColumnPosition(tstate.visibleColumn); + } + + @Benchmark + @BenchmarkMode({ Mode.Throughput }) + public List benchFindHiddenRegionPositions( + HiddenColsAndStartState tstate) + { + return tstate.h.findHiddenRegionPositions(); + } + + @Benchmark + @BenchmarkMode({ Mode.Throughput }) + public ArrayList benchGetHiddenColumnsCopy( + HiddenColsAndStartState tstate) + { + return tstate.h.getHiddenColumnsCopy(); + } + + @Benchmark + @BenchmarkMode({ Mode.Throughput }) + public int benchGetSize(HiddenColsAndStartState tstate) + { + return tstate.h.getSize(); + } + + @Benchmark + @BenchmarkMode({ Mode.Throughput }) + public HiddenColumns benchHideCols(HiddenColsAndStartState tstate) + { + tstate.h.hideColumns(tstate.visibleColumn, tstate.visibleColumn + 2000); + return tstate.h; + } + + @Benchmark + @BenchmarkMode({ Mode.Throughput }) + public boolean benchIsVisible(HiddenColsAndStartState tstate) + { + return tstate.h.isVisible(tstate.hiddenColumn); + } + + @Benchmark + @BenchmarkMode({ Mode.Throughput }) + public HiddenColumns benchReveal(HiddenColsAndStartState tstate) + { + ColumnSelection sel = new ColumnSelection(); + tstate.h.revealHiddenColumns(tstate.hiddenColumn, sel); + return tstate.h; + } + + @Benchmark + @BenchmarkMode({ Mode.Throughput }) + public HiddenColumns benchRevealAll(HiddenColsAndStartState tstate) + { + ColumnSelection sel = new ColumnSelection(); + tstate.h.revealAllHiddenColumns(sel); + return tstate.h; + } + } \ No newline at end of file