Add deserialization benchmark to BitmapCreationBenchmark

This commit is contained in:
Charles Allen 2014-11-13 13:43:14 -08:00
parent 483b2c7be0
commit 648759e9f6
1 changed files with 12 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
import java.nio.ByteBuffer;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -104,6 +105,7 @@ public class BitmapCreationBenchmark extends AbstractBenchmark
ImmutableBitmap baseImmutableBitmap; ImmutableBitmap baseImmutableBitmap;
MutableBitmap baseMutableBitmap; MutableBitmap baseMutableBitmap;
byte[] baseBytes; byte[] baseBytes;
ByteBuffer baseByteBuffer;
@Before @Before
public void setup() public void setup()
@ -114,6 +116,7 @@ public class BitmapCreationBenchmark extends AbstractBenchmark
} }
baseImmutableBitmap = factory.makeImmutableBitmap(baseMutableBitmap); baseImmutableBitmap = factory.makeImmutableBitmap(baseMutableBitmap);
baseBytes = baseImmutableBitmap.toBytes(); baseBytes = baseImmutableBitmap.toBytes();
baseByteBuffer = ByteBuffer.wrap(baseBytes);
} }
@ -159,4 +162,13 @@ public class BitmapCreationBenchmark extends AbstractBenchmark
Assert.assertArrayEquals(baseBytes, immutableBitmap.toBytes()); Assert.assertArrayEquals(baseBytes, immutableBitmap.toBytes());
} }
@BenchmarkOptions(warmupRounds = 10, benchmarkRounds = 1000)
@Test
public void testFromImmutableByteArray()
{
ImmutableBitmap immutableBitmap = factory.mapImmutableBitmap(baseByteBuffer);
Assert.assertEquals(numBits, immutableBitmap.size());
}
} }