本文整理匯總了Java中org.HdrHistogram.Histogram類的典型用法代碼示例。如果您正苦於以下問題:Java Histogram類的具體用法?Java Histogram怎麽用?Java Histogram使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Histogram類屬於org.HdrHistogram包,在下文中一共展示了Histogram類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: interval
import org.HdrHistogram.Histogram; //導入依賴的package包/類
public Snapshot interval() {
final IntervalCount requestCount = count.interval();
final IntervalCount responseTimeCount = responseTime.interval();
final Histogram h = latency.getIntervalHistogram(histogram);
final long c = requestCount.count();
final double x = requestCount.rate();
final long satisfied = h.getCountBetweenValues(0, goalLatency);
final long tolerating = h.getCountBetweenValues(goalLatency, goalLatency * 4);
final double p50 = h.getValueAtPercentile(50) * 1e-6;
final double p90 = h.getValueAtPercentile(90) * 1e-6;
final double p99 = h.getValueAtPercentile(99) * 1e-6;
final double p999 = h.getValueAtPercentile(99.9) * 1e-6;
this.histogram = h;
final double r, n, apdex;
if (c == 0) {
r = n = apdex = 0;
} else {
r = responseTimeCount.rate() / c * 1e-6;
n = x * r;
apdex = Math.min(1.0, (satisfied + (tolerating / 2.0)) / c);
}
return new AutoValue_Snapshot(c, x, n, r, p50, p90, p99, p999, apdex);
}
示例2: exportMeasurements
import org.HdrHistogram.Histogram; //導入依賴的package包/類
/**
* This is called from a main thread, on orderly termination.
*/
@Override public void exportMeasurements(MeasurementsExporter exporter) throws IOException {
// accumulate the last interval which was not caught by status thread
Histogram intervalHistogram = getIntervalHistogramAndAccumulate();
if (histogramLogWriter != null) {
histogramLogWriter.outputIntervalHistogram(intervalHistogram);
// we can close now
log.close();
}
exporter.write(getName(), "Operations", totalHistogram.getTotalCount());
exporter.write(getName(), "AverageLatency(us)", totalHistogram.getMean());
exporter.write(getName(), "MinLatency(us)", totalHistogram.getMinValue());
exporter.write(getName(), "MaxLatency(us)", totalHistogram.getMaxValue());
for (Double percentile : percentiles) {
exporter.write(getName(), ordinal(percentile) + "PercentileLatency(us)",
totalHistogram.getValueAtPercentile(percentile));
}
exportStatusCounts(exporter);
}
示例3: getSummary
import org.HdrHistogram.Histogram; //導入依賴的package包/類
/**
* This is called periodically from the StatusThread. There's a single
* StatusThread per Client process. We optionally serialize the interval to
* log on this opportunity.
*
* @see ditb.ycsb.measurements.OneMeasurement#getSummary()
*/
@Override public String getSummary() {
Histogram intervalHistogram = getIntervalHistogramAndAccumulate();
// we use the summary interval as the histogram file interval.
if (histogramLogWriter != null) {
histogramLogWriter.outputIntervalHistogram(intervalHistogram);
}
DecimalFormat d = new DecimalFormat("#.##");
return "[" + getName() + ": Count=" + intervalHistogram.getTotalCount() + ", Max="
+ intervalHistogram.getMaxValue() + ", Min=" + intervalHistogram.getMinValue() + ", Avg="
+ d.format(intervalHistogram.getMean()) + ", 90=" + d
.format(intervalHistogram.getValueAtPercentile(90)) + ", 99=" + d
.format(intervalHistogram.getValueAtPercentile(99)) + ", 99.9=" + d
.format(intervalHistogram.getValueAtPercentile(99.9)) + ", 99.99=" + d
.format(intervalHistogram.getValueAtPercentile(99.99)) + "]";
}
示例4: recordLatency
import org.HdrHistogram.Histogram; //導入依賴的package包/類
public static long recordLatency(long lastNow, Histogram h, DataInputBlobReader<RawDataSchema> reader) {
long timeMessageWasSentDelta = reader.readPackedLong();
lastNow += timeMessageWasSentDelta;
//Note after the message is decoded the latency for the message must be computed using.
long latency = System.nanoTime() - lastNow;
if (latency>=0 && 0!=lastNow) {//conditional to protect against numerical overflow, see docs on nanoTime();
try {
h.recordValue(latency);
} catch (ArrayIndexOutOfBoundsException outofbounds) {
//do not record
System.out.println("warning latency:"+latency+" was out of bounds");
}
}
return lastNow;
}
示例5: run
import org.HdrHistogram.Histogram; //導入依賴的package包/類
@Override
public void run() {
int j = batchSize; //max to check before returning thread.
int pos = position;
Histogram[] localHists = recorderOn ? hists : null;
while (--j>=0) {
if (--pos<0) {
pos = inputs.length-1;
}
//can pass in null for local hists when not gatering history
consumeSamples(pos, inputs, localHists, pctFull);
}
position = pos;
}
示例6: recordPctFull
import org.HdrHistogram.Histogram; //導入依賴的package包/類
private void recordPctFull(int pos, Histogram[] localHists, short[] pctFullAvg, long consumed, long head, long tail,
int ringSize, int msgSkipped) {
if (msgSkipped>10 && --reportSlowSpeed>0) {
logger.warn("warning {} samples skipped, telemery read is not keeping up with data", msgSkipped);
//this should not happen unless the system is overloaded and scheduler needs to be updated.
}
int pctFull = (int)((10000*(head-tail))/ringSize);
if (null!=localHists && head>=0 && tail>=0) {
//bounds enforcement because both head and tail are snapshots and are not synchronized to one another.
localHists[pos].recordValue(pctFull>=0 ? (pctFull<=10000 ? pctFull : 9999) : 0);
}
pctFullAvg[pos] = (short)Math.min(9999, (((99*pctFullAvg[pos])+pctFull)/100));
trafficValues[this.observedPipeId[pos]] = consumed;
}
示例7: runBenchmark
import org.HdrHistogram.Histogram; //導入依賴的package包/類
public void runBenchmark() throws IOException
{
while (true)
{
try (SocketChannel socketChannel = open())
{
logon(socketChannel);
final TestRequestEncoder testRequest = setupTestRequest();
final HeaderEncoder header = testRequest.header();
final Histogram histogram = new Histogram(3);
runWarmup(socketChannel, testRequest, header, histogram);
parkAfterWarmup();
runTimedRuns(socketChannel, testRequest, header, histogram);
}
}
}
示例8: runTimedRuns
import org.HdrHistogram.Histogram; //導入依賴的package包/類
private void runTimedRuns(
final SocketChannel socketChannel,
final TestRequestEncoder testRequest,
final HeaderEncoder header,
final Histogram histogram)
throws IOException
{
histogram.reset();
for (int i = 0; i < MESSAGES_EXCHANGED; i++)
{
exchangeMessage(socketChannel, testRequest, header, WARMUP_MESSAGES + i, histogram);
}
HistogramLogReader.prettyPrint(
System.currentTimeMillis(), histogram, "Client in Micros", 1000);
}
示例9: exchangeMessage
import org.HdrHistogram.Histogram; //導入依賴的package包/類
private void exchangeMessage(
final SocketChannel socketChannel,
final TestRequestEncoder testRequest,
final HeaderEncoder header,
final int index,
final Histogram histogram)
throws IOException
{
header.msgSeqNum(index + 2);
timestampEncoder.encode(System.currentTimeMillis());
final long result = testRequest.encode(writeFlyweight, 0);
final long sendingTime = System.nanoTime();
write(socketChannel, result);
read(socketChannel);
final long returnTime = System.nanoTime();
histogram.recordValue(returnTime - sendingTime);
}
示例10: main
import org.HdrHistogram.Histogram; //導入依賴的package包/類
public static void main(String[] args) throws SuspendExecution, InterruptedException {
final IntervalGenerator intervalGen = new ConstantIntervalGenerator(10000000);
final RequestExecutor<EchoRequest, EchoResponse> requestExector = new EchoRequestExecutor();
final Channel<EchoRequest> requestCh = Channels.newChannel(-1);
final Channel<TimingEvent<EchoResponse>> eventCh = Channels.newChannel(-1);
// Requests generator
new Fiber<Void>("req-gen", () -> {
for (int i=0; i < 1000; ++i) {
final EchoRequest req = new EchoRequest();
req.setMessage("foo");
requestCh.send(req);
}
requestCh.close();
}).start();
final Histogram histogram = new Histogram(3600000000L, 3);
// Event recording, both HistHDR and logging
record(eventCh, new HdrHistogramRecorder(histogram, 1000000), new LoggingRecorder(LOG));
JBender.loadTestThroughput(intervalGen, 0, requestCh, requestExector, eventCh);
histogram.outputPercentileDistribution(System.out, 1000.0);
}
示例11: ClientRunner
import org.HdrHistogram.Histogram; //導入依賴的package包/類
public ClientRunner(Session<UUID> client, Histogram rttHistogram, int orders, int batchSize,
int ordersPerPacket, long batchPauseMillis) {
this.client = client;
this.rttHistogram = rttHistogram;
final long highestTrackableValue = TimeUnit.MINUTES.toNanos(1);
final int numberOfSignificantValueDigits = 3;
burstHistogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
this.orders = orders;
this.batchSize = batchSize;
this.ordersPerPacket = ordersPerPacket;
this.batchPauseMillis = batchPauseMillis;
System.arraycopy("client00000000".getBytes(), 0, clOrdId, 0, 14);
clOrdIdBuffer = ByteBuffer.wrap(clOrdId);
}
示例12: printStats
import org.HdrHistogram.Histogram; //導入依賴的package包/類
private static void printStats(Histogram data) {
long totalCount = data.getTotalCount();
System.out.println("Total count: " + totalCount);
if (totalCount > 0) {
System.out.println("MIN\tMAX\tMEAN\t30%\t50%\t90%\t95%\t99%\t99.99%\tSTDDEV");
System.out.format("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
TimeUnit.NANOSECONDS.toMicros(data.getMinValue()),
TimeUnit.NANOSECONDS.toMicros(data.getMaxValue()),
TimeUnit.NANOSECONDS.toMicros((long) data.getMean()),
TimeUnit.NANOSECONDS.toMicros(data.getValueAtPercentile(30.0)),
TimeUnit.NANOSECONDS.toMicros(data.getValueAtPercentile(50.0)),
TimeUnit.NANOSECONDS.toMicros(data.getValueAtPercentile(90.0)),
TimeUnit.NANOSECONDS.toMicros(data.getValueAtPercentile(95.0)),
TimeUnit.NANOSECONDS.toMicros(data.getValueAtPercentile(99.0)),
TimeUnit.NANOSECONDS.toMicros(data.getValueAtPercentile(99.99)),
TimeUnit.NANOSECONDS.toMicros((long) data.getStdDeviation()));
}
}
示例13: exmapleUsageTest
import org.HdrHistogram.Histogram; //導入依賴的package包/類
@Ignore
public void exmapleUsageTest() {
CPUMonitor monitor = new CPUMonitor(200); //5 per second
monitor.start();
try {
Thread.sleep(900);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
Histogram histogram = monitor.stop();
assertTrue(null!=histogram);
if (histogram.getTotalCount()>0) {//some platforms do not support this monitor.
assertEquals(5, histogram.getTotalCount());
}
PrintStream printStream = new PrintStream(new ByteArrayOutputStream());
histogram.outputPercentileDistribution(printStream, CPUMonitor.UNIT_SCALING_RATIO);
}
示例14: run
import org.HdrHistogram.Histogram; //導入依賴的package包/類
@Override
public void run(final MessageConsumerCoordinator messageConsumerCoordinator,
final MessageProducerCoordinator messageProducerCoordinator,
final int numConsumers,
final int numProducers,
final long totalNumberOfMessages,
final Report report) {
CompletionService<Histogram> producerCompletionService = messageProducerCoordinator.startProducers();
// Producer / No Consumer
Stopwatch producerStartTime = Stopwatch.createStarted();
report.aggregateAndPrintResults(CoordinatorType.PRODUCER, producerCompletionService, numProducers, totalNumberOfMessages, producerStartTime);
// Now, let's start some consumers with producers
final CompletionService<Histogram> consumerCompletionService = messageConsumerCoordinator.startConsumers();
producerCompletionService = messageProducerCoordinator.startProducers();
producerStartTime = Stopwatch.createStarted();
final Stopwatch consumerStartTime = Stopwatch.createStarted();
report.aggregateAndPrintResults(CoordinatorType.PRODUCER, producerCompletionService, numProducers, totalNumberOfMessages, producerStartTime);
report.aggregateAndPrintResults(CoordinatorType.CONSUMER, consumerCompletionService, numConsumers, totalNumberOfMessages, consumerStartTime);
}
示例15: run
import org.HdrHistogram.Histogram; //導入依賴的package包/類
@Override
public void run(final MessageConsumerCoordinator messageConsumerCoordinator,
final MessageProducerCoordinator messageProducerCoordinator,
final int numConsumers,
final int numProducers,
final long totalNumberOfMessages,
final Report report) {
final CompletionService<Histogram> consumerCompletionService = messageConsumerCoordinator.startConsumers();
final CompletionService<Histogram> producerCompletionService = messageProducerCoordinator.startProducers();
// Note that the timer is started after startConsumers() and startProducers(), this is by purpose to exclude the initialization time.
final Stopwatch producerStartTime = Stopwatch.createStarted();
final Stopwatch consumerStartTime = Stopwatch.createStarted();
report.aggregateAndPrintResults(CoordinatorType.PRODUCER, producerCompletionService, numProducers, totalNumberOfMessages, producerStartTime);
report.aggregateAndPrintResults(CoordinatorType.CONSUMER, consumerCompletionService, numConsumers, totalNumberOfMessages, consumerStartTime);
}