-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
998 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<parent> | ||
<artifactId>jetty-toolchain</artifactId> | ||
<groupId>org.eclipse.jetty.toolchain</groupId> | ||
<version>1.7</version> | ||
<relativePath>../jetty-toolchain</relativePath> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>jetty-perf-helper</artifactId> | ||
<packaging>jar</packaging> | ||
<version>1.0.8-SNAPSHOT</version> | ||
<name>Jetty Toolchain :: Performance Helper</name> | ||
<description>Performance/Benchmark Support for Jetty</description> | ||
|
||
<scm> | ||
<connection>scm:git:git://github.com/eclipse/jetty.toolchain.git</connection> | ||
<developerConnection>scm:git:ssh://[email protected]/eclipse/jetty.toolchain.git</developerConnection> | ||
<url>https://github.com/eclipse/jetty.toolchain/tree/master/jetty-perf-helper</url> | ||
</scm> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.hdrhistogram</groupId> | ||
<artifactId>HdrHistogram</artifactId> | ||
<version>2.1.12</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> | ||
|
122 changes: 122 additions & 0 deletions
122
src/main/java/org/eclipse/jetty/toolchain/perf/HistogramSnapshot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. | ||
// ------------------------------------------------------------------------ | ||
// All rights reserved. This program and the accompanying materials | ||
// are made available under the terms of the Eclipse Public License v1.0 | ||
// and Apache License v2.0 which accompanies this distribution. | ||
// | ||
// The Eclipse Public License is available at | ||
// http://www.eclipse.org/legal/epl-v10.html | ||
// | ||
// The Apache License v2.0 is available at | ||
// http://www.opensource.org/licenses/apache2.0.php | ||
// | ||
// You may elect to redistribute this code under either of these licenses. | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.toolchain.perf; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import org.HdrHistogram.Histogram; | ||
import org.HdrHistogram.HistogramIterationValue; | ||
|
||
public class HistogramSnapshot implements MeasureConverter | ||
{ | ||
private final Histogram histogram; | ||
private final long buckets; | ||
private final String name; | ||
private final String unit; | ||
private final MeasureConverter converter; | ||
|
||
public HistogramSnapshot(Histogram histogram) | ||
{ | ||
this(histogram, 32); | ||
} | ||
|
||
public HistogramSnapshot(Histogram histogram, long buckets) | ||
{ | ||
this(histogram, buckets, "Measures", "ms", null); | ||
} | ||
|
||
public HistogramSnapshot(Histogram histogram, long buckets, String name, String unit, MeasureConverter converter) | ||
{ | ||
this.histogram = histogram; | ||
this.buckets = buckets; | ||
this.name = name; | ||
this.unit = unit; | ||
this.converter = converter == null ? this : converter; | ||
} | ||
|
||
@Override | ||
public long convert(long measure) | ||
{ | ||
return TimeUnit.NANOSECONDS.toMillis(measure); | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
StringBuilder builder = new StringBuilder(); | ||
|
||
long range = histogram.getMaxValue(); | ||
|
||
long maxBucketCount = 0; | ||
for (HistogramIterationValue value : histogram.linearBucketValues(range / buckets)) | ||
{ | ||
long bucketCount = value.getCountAddedInThisIterationStep(); | ||
if (bucketCount > maxBucketCount) | ||
maxBucketCount = bucketCount; | ||
} | ||
|
||
double previousPercentile = 0; | ||
for (HistogramIterationValue value : histogram.linearBucketValues(range / buckets)) | ||
{ | ||
long bucketCount = value.getCountAddedInThisIterationStep(); | ||
|
||
// Draw the ASCII "gaussian" point. | ||
long point = maxBucketCount == 0 ? 0 : Math.round((double)bucketCount / maxBucketCount * buckets); | ||
if (point == buckets) | ||
--point; | ||
for (long j = 0; j < point; ++j) | ||
builder.append(" "); | ||
builder.append("@"); | ||
for (long j = point + 1; j < buckets; ++j) | ||
builder.append(" "); | ||
|
||
// Print the measure and its frequency. | ||
builder.append(" _ "); | ||
builder.append(String.format("%,d %s (%d, %.2f%%)", | ||
converter.convert(value.getValueIteratedTo()), | ||
unit, | ||
bucketCount, | ||
100D * bucketCount / histogram.getTotalCount())); | ||
double percentile = value.getPercentile(); | ||
if (previousPercentile < 50D && percentile >= 50D) | ||
builder.append(" ^50%"); | ||
if (previousPercentile < 85D && percentile >= 85D) | ||
builder.append(" ^85%"); | ||
if (previousPercentile < 95D && percentile >= 95D) | ||
builder.append(" ^95%"); | ||
if (previousPercentile < 99D && percentile >= 99D) | ||
builder.append(" ^99%"); | ||
if (previousPercentile < 99.9D && percentile >= 99.9D) | ||
builder.append(" ^99.9%"); | ||
previousPercentile = percentile; | ||
builder.append(System.lineSeparator()); | ||
} | ||
|
||
builder.append(String.format("%s: %d samples | min/avg/50th%%/99th%%/max = %,d/%,d/%,d/%,d/%,d %s", | ||
name, | ||
histogram.getTotalCount(), | ||
converter.convert(histogram.getMinValue()), | ||
converter.convert(Math.round(histogram.getMean())), | ||
converter.convert(histogram.getValueAtPercentile(50D)), | ||
converter.convert(histogram.getValueAtPercentile(99D)), | ||
converter.convert(histogram.getMaxValue()), | ||
unit)); | ||
|
||
return builder.toString(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/eclipse/jetty/toolchain/perf/MeasureConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. | ||
// ------------------------------------------------------------------------ | ||
// All rights reserved. This program and the accompanying materials | ||
// are made available under the terms of the Eclipse Public License v1.0 | ||
// and Apache License v2.0 which accompanies this distribution. | ||
// | ||
// The Eclipse Public License is available at | ||
// http://www.eclipse.org/legal/epl-v10.html | ||
// | ||
// The Apache License v2.0 is available at | ||
// http://www.opensource.org/licenses/apache2.0.php | ||
// | ||
// You may elect to redistribute this code under either of these licenses. | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.toolchain.perf; | ||
|
||
public interface MeasureConverter | ||
{ | ||
public long convert(long measure); | ||
} |
Oops, something went wrong.