mirror of https://github.com/apache/druid.git
Use Blackhole objects to sink the method return in a benchmak loop (JMH) (#5908)
* Remove the unsafe loop from the benchmark * Removing unused variables
This commit is contained in:
parent
5ee7b0cada
commit
e4ef753a60
|
@ -80,11 +80,9 @@ public class FloatCompressionBenchmark
|
||||||
{
|
{
|
||||||
ColumnarFloats columnarFloats = supplier.get();
|
ColumnarFloats columnarFloats = supplier.get();
|
||||||
int count = columnarFloats.size();
|
int count = columnarFloats.size();
|
||||||
float sum = 0;
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
sum += columnarFloats.get(i);
|
bh.consume(columnarFloats.get(i));
|
||||||
}
|
}
|
||||||
bh.consume(sum);
|
|
||||||
columnarFloats.close();
|
columnarFloats.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,11 +91,9 @@ public class FloatCompressionBenchmark
|
||||||
{
|
{
|
||||||
ColumnarFloats columnarFloats = supplier.get();
|
ColumnarFloats columnarFloats = supplier.get();
|
||||||
int count = columnarFloats.size();
|
int count = columnarFloats.size();
|
||||||
float sum = 0;
|
|
||||||
for (int i = 0; i < count; i += rand.nextInt(2000)) {
|
for (int i = 0; i < count; i += rand.nextInt(2000)) {
|
||||||
sum += columnarFloats.get(i);
|
bh.consume(columnarFloats.get(i));
|
||||||
}
|
}
|
||||||
bh.consume(sum);
|
|
||||||
columnarFloats.close();
|
columnarFloats.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,11 +83,9 @@ public class LongCompressionBenchmark
|
||||||
{
|
{
|
||||||
ColumnarLongs columnarLongs = supplier.get();
|
ColumnarLongs columnarLongs = supplier.get();
|
||||||
int count = columnarLongs.size();
|
int count = columnarLongs.size();
|
||||||
long sum = 0;
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
sum += columnarLongs.get(i);
|
bh.consume(columnarLongs.get(i));
|
||||||
}
|
}
|
||||||
bh.consume(sum);
|
|
||||||
columnarLongs.close();
|
columnarLongs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,11 +94,9 @@ public class LongCompressionBenchmark
|
||||||
{
|
{
|
||||||
ColumnarLongs columnarLongs = supplier.get();
|
ColumnarLongs columnarLongs = supplier.get();
|
||||||
int count = columnarLongs.size();
|
int count = columnarLongs.size();
|
||||||
long sum = 0;
|
|
||||||
for (int i = 0; i < count; i += rand.nextInt(2000)) {
|
for (int i = 0; i < count; i += rand.nextInt(2000)) {
|
||||||
sum += columnarLongs.get(i);
|
bh.consume(columnarLongs.get(i));
|
||||||
}
|
}
|
||||||
bh.consume(sum);
|
|
||||||
columnarLongs.close();
|
columnarLongs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue