2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
24 import org.jalview.HiddenColumnsBenchmark.HiddenColsAndStartState;
25 import org.openjdk.jmh.annotations.Benchmark;
26 import org.openjdk.jmh.annotations.BenchmarkMode;
27 import org.openjdk.jmh.annotations.Fork;
28 import org.openjdk.jmh.annotations.Measurement;
29 import org.openjdk.jmh.annotations.Mode;
30 import org.openjdk.jmh.annotations.Setup;
31 import org.openjdk.jmh.annotations.State;
32 import org.openjdk.jmh.annotations.Warmup;
33 import org.openjdk.jmh.annotations.Scope;
34 import org.openjdk.jmh.annotations.Param;
36 import java.util.ArrayList;
37 import java.util.List;
38 import java.util.Random;
39 import java.util.concurrent.TimeUnit;
41 import jalview.datamodel.Alignment;
42 import jalview.datamodel.AlignmentI;
43 import jalview.datamodel.Sequence;
44 import jalview.datamodel.SequenceI;
47 * A class to benchmark hidden columns performance
49 @Warmup(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
50 @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
52 public class SeqWidthBenchmark {
55 * State with multiple hidden columns and a start position set
58 public static class AlignmentState
60 @Param({"100", "1000", "10000", "100000"})
63 Random rand = new Random();
72 SequenceI[] seqs = new Sequence[numSeqs];
73 for (int i = 0; i < numSeqs; i++)
75 int count = rand.nextInt(10000);
76 StringBuilder aas = new StringBuilder();
77 for (int j=0; j<count; j++)
82 seqs[i] = new Sequence("Sequence" + i, aas.toString());
84 al = new Alignment(seqs);
90 @BenchmarkMode({Mode.Throughput})
91 public int benchSeqGetWidth(AlignmentState tstate)
93 return tstate.al.getWidth();