summaryrefslogtreecommitdiffstats
path: root/container-core/src/test/java/com/yahoo
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-06-30 00:56:40 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2022-06-30 00:59:43 +0200
commit636f8a0b266e61bfb3daf780aebbbf93980c5d9f (patch)
tree6216c2d35ea1b6077a48f25eba5893ca653ab10d /container-core/src/test/java/com/yahoo
parent90a9f7a3ccf1f29bd1e3ced4368e373dd1193fd8 (diff)
Rewrite to use native arrays instead of List<String> => Cpu cost cut in half.
Diffstat (limited to 'container-core/src/test/java/com/yahoo')
-rw-r--r--container-core/src/test/java/com/yahoo/processing/request/test/CompoundNameBenchmark.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/container-core/src/test/java/com/yahoo/processing/request/test/CompoundNameBenchmark.java b/container-core/src/test/java/com/yahoo/processing/request/test/CompoundNameBenchmark.java
index 81ddc42f6c3..144c3cf736e 100644
--- a/container-core/src/test/java/com/yahoo/processing/request/test/CompoundNameBenchmark.java
+++ b/container-core/src/test/java/com/yahoo/processing/request/test/CompoundNameBenchmark.java
@@ -9,34 +9,37 @@ import com.yahoo.processing.request.CompoundName;
public class CompoundNameBenchmark {
public void run() {
long result=0;
- String strings[] = createStrings(1000);
+ String [] strings = createStrings(1000);
// Warm-up
out("Warming up...");
- for (int i=0; i<10*1000; i++)
+ for (int i=0; i<2*1000; i++)
result+=createCompundName(strings);
long startTime=System.currentTimeMillis();
out("Running...");
- for (int i=0; i<100*1000; i++)
+ for (int i=0; i<10*1000; i++)
result+=createCompundName(strings);
out("Ignore this: " + result); // Make sure we are not fooled by optimization by creating an observable result
long endTime=System.currentTimeMillis();
out("Compoundification 1000 strings 100.000 times took " + (endTime-startTime) + " ms");
}
- private final String [] createStrings(int num) {
- String strings [] = new String [num];
+ private String [] createStrings(int num) {
+ String [] strings = new String [num];
for(int i=0; i < strings.length; i++) {
strings[i] = "this.is.a.short.compound.name." + i;
}
return strings;
}
- private final int createCompundName(String [] strings) {
+ private int createCompundName(String [] strings) {
int retval = 0;
- for (int i=0; i < strings.length; i++) {
- CompoundName n = new CompoundName(strings[i]);
+ CompoundName toAppend = new CompoundName("appended.twice");
+ for (String s : strings) {
+ CompoundName n = new CompoundName(s);
retval += n.size();
+ CompoundName a = n.append(toAppend);
+ retval += a.size();
}
return retval;
}