Skip to content

Instantly share code, notes, and snippets.

@Test
public void testLog() {
Object[] array = new Object[] {1, 2};
double avg = 0.0;
for (int x = 0; x < 1000; x++) {
long start = System.currentTimeMillis();
for (int i = 0; i < 100_000_000; i++) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("a {} string {}", array[0], array[1]);
}
Result "testWithoutIf":
905846726.800 ±(99.9%) 3858743.057 ops/s [Average]
(min, avg, max) = (836690777.086, 905846726.800, 943887137.592), stdev = 16338159.725
CI (99.9%): [901987983.743, 909705469.857] (assumes normal distribution)
# Run complete. Total time: 00:06:45
Benchmark Mode Cnt Score Error Units
MyBenchmark.testWithoutIf thrpt 200 905846726.800 ± 3858743.057 ops/s
package org.sample;
import org.apache.lucene.util.LongBitSet;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.openjdk.jmh.annotations.Benchmark;
import java.util.ArrayList;
public class MyBenchmark {
Benchmark Mode Cnt Score Error Units
MyBenchmark.testCustomBitSetSmall thrpt 10 143.324 ± 24.399 ops/s
MyBenchmark.testCustomBitSetWrapperLarge thrpt 10 0.251 ± 0.163 ops/s
MyBenchmark.testLuceneBitSetGrowByDoubleLarge thrpt 10 51.219 ± 1.172 ops/s
MyBenchmark.testLuceneBitSetGrowByDoubleSmall thrpt 10 5278.155 ± 204.776 ops/s
MyBenchmark.testLuceneBitSetGrowByOneLarge thrpt 10 40.555 ± 1.277 ops/s
MyBenchmark.testLuceneBitSetGrowByOneSmall thrpt 10 4125.909 ± 200.244 ops/s
Benchmark Mode Cnt Score Error Units
MyBenchmark.testLuceneBitSetGrowByDoubleLarge thrpt 10 5.098 ± 0.152 ops/s
MyBenchmark.testLuceneBitSetGrowByDoubleSmall thrpt 10 521.420 ± 23.501 ops/s
MyBenchmark.testLuceneBitSetGrowByOneLarge thrpt 10 3.763 ± 0.227 ops/s
MyBenchmark.testLuceneBitSetGrowByOneSmall thrpt 10 407.312 ± 14.617 ops/s
private class CustomBitSetList {
final int bucket_size = 1024;
int offset = -1;
int currentBucketIdx = 0;
ArrayList<FixedBitSet> buckets = new ArrayList<>(16);
FixedBitSet currentBucket = new FixedBitSet(bucket_size);
CustomBitSetList() {
----
select a as x from t1
union all
select d from t2
order by x limit 2
1st rel:
collect: _docId, a from t1
merge: apply ordering by a and limit 2
@matriv
matriv / gist:e6add07ea690bd13562bc6686f2c851d
Last active November 18, 2016 11:32
Union Fetch-Order by examples
select x1, y1, z1 from t1
union all
select x2, y2, z2 from (select * from t2 order by y2 limit 10) b
order by 1
select t1.fetchid, x1, null from t1 order by x1
select t2.fetchid, x2, y2 from t2 order by y2 limit 10
order by (IC(1))
Fetch:
select x1, y1, z1 from t1
union all
select x2, y2, z2 from (select * from t2 order by y2 limit 10) b
order by 1
select t1.fetchid, x1, null from t1 order by x1
select t2.fetchid, x2, y2 from t2 order by y2 limit 10
order by (IC(1))
Fetch:
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put("threadpool.bulk.type", "fixed")
.put("threadpool.bulk.queue_size", "500")
.put("threadpool.bulk.processors", "8")
.build();
}