Skip to content

Commit

Permalink
atlas JMH: Quantify skipping decoding of the time series ID
Browse files Browse the repository at this point in the history
when decoding batches of datapoints.
  • Loading branch information
manolama committed Feb 16, 2024
1 parent fe78706 commit b86a613
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import scala.util.Using
* ```
* Benchmark Mode Cnt Score Error Units
* decodeBatch thrpt 5 23.787 ± 1.148 ops/s
* decodeBatchDatapoints thrpt 5 129.900 ± 3.767 ops/s
* decodeCompactBatch thrpt 5 173.148 ± 1.835 ops/s
* decodeList thrpt 5 25.277 ± 0.254 ops/s
* encodeBatch thrpt 5 179.382 ± 39.696 ops/s
Expand Down Expand Up @@ -76,6 +77,13 @@ class PublishPayloadsBench {
}
}

// Skips the ID calculation.
private def decodeBatchDatapoints(data: Array[Byte]): List[Datapoint] = {
Using.resource(Json.newSmileParser(new ByteArrayInputStream(data))) { parser =>
PublishPayloads.decodeBatchDatapoints(parser)
}
}

private def encodeBatch(values: List[DatapointTuple]): Array[Byte] = {
Streams.byteArray { out =>
Using.resource(Json.newSmileGenerator(out)) { gen =>
Expand Down Expand Up @@ -126,6 +134,14 @@ class PublishPayloadsBench {
}
}

@Benchmark
def decodeBatchDatapoints(bh: Blackhole): Unit = {
val consumer = new BlackholePublishConsumer(bh)
decodeBatchDatapoints(encodedBatch).foreach { d =>
consumer.consume(null, d.tags, d.timestamp, d.value)
}
}

@Benchmark
def decodeCompactBatch(bh: Blackhole): Unit = {
val consumer = new BlackholePublishConsumer(bh)
Expand Down

0 comments on commit b86a613

Please sign in to comment.