blob: f5f92815d65766503cd68670d90ed4b343b3b425 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.text;
/**
* It is what it says
*
* @author bratseth
*/
public class XMLMicroBenchmark {
public void benchmark(int sizeInK) {
System.out.println("Warming up...");
escapeStrings(1000); // warm-up
System.out.println("Starting benchmark...");
long startTime=System.currentTimeMillis();
escapeStrings(sizeInK);
long endTime=System.currentTimeMillis();
System.out.println("Done.\nEscaping " + sizeInK + "k strings took " + (endTime-startTime) + "ms");
}
private void escapeStrings(int sizeInK) {
for (int i=0; i<1000*sizeInK; i++) {
XML.xmlEscape("foobar" + i,true,true,'\u001f');
}
}
public static void main(String[] args) {
new XMLMicroBenchmark().benchmark(10000);
}
}
|