MCPcopy Create free account
hub / github.com/BaseXdb/basex / test

Method test

basex-tests/src/test/java/org/basex/server/XMarkTest.java:147–199  ·  view source on GitHub ↗

Runs all tests and generates some test output. @throws Exception any exception

()

Source from the content-addressed store, hash-verified

145 * @throws Exception any exception
146 */
147 @Test public void test() throws Exception {
148 final IntList exclude = new IntList(new int[] { 11, 12 });
149 final TokenBuilder tb = new TokenBuilder().add(DB).add(Prop.NL);
150
151 try(ClientSession cs = createClient(USER, USER)) {
152 cs.execute(new Open(DB));
153
154 // ignore first run
155 System.out.println("Warming up...");
156 for(int i = 1; i <= 20; i++) {
157 if(!exclude.contains(i)) {
158 try(ClientQuery cq = cs.query(QUERIES[i - 1])) {
159 final Performance p = new Performance();
160 cq.execute();
161 System.out.println(i + ": " + p);
162 } catch(final BaseXException ex) {
163 // too slow queries will be stopped after client timeout
164 System.out.println(i + ": " + ex);
165 exclude.add(i);
166 }
167 }
168 }
169
170 System.out.println(Prop.NL + "Testing...");
171 for(int i = 1; i <= 20; i++) {
172 tb.add(String.format("%02d", i)).add(" ");
173 final BigDecimal max = BigDecimal.valueOf(MAX);
174 try(ClientQuery cq = cs.query(QUERIES[i - 1])) {
175 if(exclude.contains(i)) {
176 tb.add("1000000");
177 } else {
178 double min = Double.MAX_VALUE;
179 BigDecimal total = BigDecimal.valueOf(0);
180 int r = 0;
181 while(total.compareTo(max) < 0) {
182 final Performance p = new Performance();
183 cq.execute();
184 final double t = Double.parseDouble(p.formatRuntime().replaceAll(" .*", ""));
185 total = total.add(BigDecimal.valueOf(t));
186 min = Math.min(min, t);
187 r++;
188 }
189 tb.add(Double.toString(min));
190 System.out.println(i + ": " + min + " (" + r + " runs, stopped at " + total + " ms)");
191 }
192 }
193 tb.add(Prop.NL);
194 }
195 }
196
197 DIR.md();
198 FILE.write(tb.finish());
199 }
200}

Callers

nothing calls this directly

Calls 15

containsMethod · 0.95
addMethod · 0.95
addMethod · 0.95
formatRuntimeMethod · 0.95
finishMethod · 0.95
createClientMethod · 0.80
mdMethod · 0.80
addMethod · 0.65
executeMethod · 0.65
toStringMethod · 0.65
printlnMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected