You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/12/04 06:30:11 UTC
[GitHub] [lucene-solr] gf2121 commented on pull request #2113: LUCENE-9629: Use computed masks
gf2121 commented on pull request #2113:
URL: https://github.com/apache/lucene-solr/pull/2113#issuecomment-738594982
Thank you for your reply @dweiss ! This is indeed something to worry about, so a silly benchmark between const values and const arrays had been run before i submited this commit:
```
public class Main {
private static final long NANO_2_MILL = 1000000;
private static final int TIMES = 100;
public static void main(String[] args) throws Exception {
//use static final longs
// ForUtil forUtil = new ForUtilWithConstValues();
//use static final arrays
ForUtil forUtil = new ForUtilWithConstArrays();
System.out.println(forUtil.getClass().getName());
DataInput dataInput = new DataInput() {
@Override
public byte readByte() throws IOException { return 0; }
@Override
public void readBytes(byte[] bytes, int i, int i1) throws IOException {}
@Override
public void readLELongs(long[] dst, int offset, int length) throws IOException {
Arrays.fill(dst, offset, offset + length, 1L);
}
};
long[] nums = new long[128];
for (int i = 0; i < 100000000; i++) {
forUtil.decode(1, dataInput, nums);
}
System.out.println("warmed");
long best = Long.MAX_VALUE;
long worst = 0L;
long sum = 0L;
for (int time = 0; time < TIMES; time++) {
long start = System.nanoTime();
for (int i = 0; i < 50000000; i++) {
forUtil.decode(1, dataInput, nums);
}
long end = System.nanoTime();
long took = end - start;
sum += took;
if (took < best) {
best = took;
} else if (took > worst) {
worst = took;
}
}
System.out.println(String.format("best: %d ms, worst: %d ms, avg: %d ms", best/NANO_2_MILL, worst/NANO_2_MILL, sum/NANO_2_MILL/TIMES));
}
}
```
And here is the result:
> org.apache.lucene.codecs.lucene84.ForUtilWithConstValues
> warmed
> best: 1275 ms, worst: 1480 ms, avg: 1326 ms
>
> org.apache.lucene.codecs.lucene84.ForUtilWithConstArrays
> warmed
> best: 1263 ms, worst: 1488 ms, avg: 1328 ms
The result looks good to me, but i'm not sure if it makes sense to you. If there are other jobs needed on the point, just tell me~
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org