in src/main/java/org/apache/datasketches/characterization/quantiles/DoublesSketchSpeedProfile.java [93:192]
public void doTrial() {
DoublesSketchAccuracyProfile.shuffle(randomInput);
final long startBuild = System.nanoTime();
final UpdateDoublesSketch updateSketch = useDirect
? builder.build(updateSketchMemory)
: builder.build();
final long stopBuild = System.nanoTime();
buildTimeNs += stopBuild - startBuild;
final long startUpdate = System.nanoTime();
for (int i = 0; i < randomInput.length; i++) {
updateSketch.update(randomInput[i]);
}
final long stopUpdate = System.nanoTime();
updateTimeNs += stopUpdate - startUpdate;
{
final long startGetQuantiles = System.nanoTime();
updateSketch.getQuantiles(orderedLittleDoubles);
final long stopGetQuantiles = System.nanoTime();
updateGetQuantilesTimeNs += stopGetQuantiles - startGetQuantiles;
final long startGetCdf = System.nanoTime();
updateSketch.getCDF(orderedLittleDoubles);
final long stopGetCdf = System.nanoTime();
updateGetCdfTimeNs += stopGetCdf - startGetCdf;
final long startGetRank = System.nanoTime();
final double[] estRanks = updateSketch.getRanks(orderedLittleDoubles);
final long stopGetRank = System.nanoTime();
updateGetRankTimeNs += stopGetRank - startGetRank;
final long startSerialize = System.nanoTime();
final byte[] bytes = updateSketch.toByteArray();
final long stopSerialize = System.nanoTime();
updateSerializeTimeNs += stopSerialize - startSerialize;
final WritableMemory mem = WritableMemory.writableWrap(bytes);
final long startDeserialize = System.nanoTime();
if (useDirect) {
UpdateDoublesSketch.wrap(mem);
} else {
UpdateDoublesSketch.heapify(mem);
}
final long stopDeserialize = System.nanoTime();
updateDeserializeTimeNs += stopDeserialize - startDeserialize;
// could record the last one since they must be the same
// but let's average across all trials to see if there is an anomaly
updateSerializedSizeBytes += bytes.length;
}
final long startCompact = System.nanoTime();
final DoublesSketch compactSketch = useDirect
? updateSketch.compact(compactSketchMemory)
: updateSketch.compact();
final long stopCompact = System.nanoTime();
compactTimeNs += stopCompact - startCompact;
{
final long startGetQuantiles = System.nanoTime();
compactSketch.getQuantiles(orderedLittleDoubles);
final long stopGetQuantiles = System.nanoTime();
compactGetQuantilesTimeNs += stopGetQuantiles - startGetQuantiles;
final long startGetCdf = System.nanoTime();
compactSketch.getCDF(orderedLittleDoubles);
final long stopGetCdf = System.nanoTime();
compactGetCdfTimeNs += stopGetCdf - startGetCdf;
final long startGetRank = System.nanoTime();
for (final double value: orderedLittleDoubles) {
//compactSketch.getRank(value);
final double estRank = compactSketch.getCDF(new double[] {value})[0];
}
final long stopGetRank = System.nanoTime();
compactGetRankTimeNs += stopGetRank - startGetRank;
final long startSerialize = System.nanoTime();
final byte[] bytes = compactSketch.toByteArray();
final long stopSerialize = System.nanoTime();
compactSerializeTimeNs += stopSerialize - startSerialize;
final Memory mem = Memory.wrap(bytes);
final long startDeserialize = System.nanoTime();
if (useDirect) {
DoublesSketch.wrap(mem);
} else {
DoublesSketch.heapify(mem);
}
final long stopDeserialize = System.nanoTime();
compactDeserializeTimeNs += stopDeserialize - startDeserialize;
// could record the last one since they must be the same
// but let's average across all trials to see if there is an anomaly
compactSerializedSizeBytes += bytes.length;
numRetainedItems += compactSketch.getNumRetained();
}
}