Skip to content

Commit

Permalink
Merge branch 'release/2.0.0-BETA16'
Browse files Browse the repository at this point in the history
  • Loading branch information
codahale committed Aug 23, 2011
2 parents 7b64036 + 35e62ff commit 953a93b
Show file tree
Hide file tree
Showing 30 changed files with 204 additions and 197 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
v2.0.0-BETA16: Aug 23 2011
==========================

* Fixed a bug in GC monitoring.


v2.0.0-BETA15: Aug 15 2011
==========================

Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Expand Up @@ -2,8 +2,9 @@ Many Many Thanks To
===================

* Bruce Mitchener (@waywardmonkeys)
* Gerolf Seitz (@seitz)
* Ciamac Moallemi (@ciamac)
* Cliff Moon (@cliffmoon)
* Gerolf Seitz (@seitz)
* James Casey (@jamesc)
* JD Maturen (@sku)
* John Ewart (@johnewart)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -35,13 +35,13 @@ How To Use
<dependency>
<groupId>com.yammer.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>2.0.0-BETA15</version>
<version>2.0.0-BETA16</version>
</dependency>
<!-- if you want the Scala façade library -->
<dependency>
<groupId>com.yammer.metrics</groupId>
<artifactId>metrics-scala_${scala.version}</artifactId>
<version>2.0.0-BETA15</version>
<version>2.0.0-BETA16</version>
</dependency>
</dependencies>
```
Expand Down
2 changes: 1 addition & 1 deletion metrics-core/pom.xml
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.yammer.metrics</groupId>
<artifactId>metrics-parent</artifactId>
<version>2.0.0-BETA15</version>
<version>2.0.0-BETA16</version>
</parent>

<groupId>com.yammer.metrics</groupId>
Expand Down
Expand Up @@ -151,7 +151,7 @@ public static long daemonThreadCount() {
public static Map<String, GarbageCollector> garbageCollectors() {
final Map<String, GarbageCollector> gcs = new HashMap<String, GarbageCollector>();
for (GarbageCollectorMXBean bean : getGarbageCollectorMXBeans()) {
gcs.put(bean.getName(), new GarbageCollector(bean.getCollectionCount(), bean.getCollectionCount()));
gcs.put(bean.getName(), new GarbageCollector(bean.getCollectionCount(), bean.getCollectionTime()));
}
return gcs;
}
Expand Down
Expand Up @@ -9,38 +9,38 @@ class CounterMetricSpec extends Spec {
val counter = new CounterMetric

@test def `starts at zero` = {
counter.count must beEqualTo(0)
counter.count.must(be(0))
}

@test def `increments by one` = {
counter.inc()

counter.count must beEqualTo(1)
counter.count.must(be(1))
}

@test def `increments by an arbitrary delta` = {
counter.inc(3)

counter.count must beEqualTo(3)
counter.count.must(be(3))
}

@test def `decrements by one` = {
counter.dec()

counter.count must beEqualTo(-1)
counter.count.must(be(-1))
}

@test def `decrements by an arbitrary delta` = {
counter.dec(3)

counter.count must beEqualTo(-3)
counter.count.must(be(-3))
}

@test def `is zero after being cleared` = {
counter.inc(3)
counter.clear()

counter.count must beEqualTo(0)
counter.count.must(be(0))
}
}
}
Expand Up @@ -12,7 +12,7 @@ class GaugeMetricSpec extends Spec {
}

@test def `return a value` = {
metric.value() must beEqualTo("woo")
metric.value().must(be("woo"))
}
}

Expand Down
Expand Up @@ -11,35 +11,35 @@ class HistogramMetricSpec extends Spec {
val histogram = new HistogramMetric(new UniformSample(100))

@test def `has a count of 0` = {
histogram.count must beEqualTo(0)
histogram.count.must(be(0))
}

@test def `has a max of 0` = {
histogram.max must beEqualTo(0)
histogram.max.must(be(0))
}

@test def `has a min of 0` = {
histogram.min must beEqualTo(0)
histogram.min.must(be(0))
}

@test def `has a mean of 0` = {
histogram.mean must beCloseTo(0.0, 0.0)
histogram.mean.must(be(approximately(0.0, 0.0)))
}

@test def `has a standard deviation of 0` = {
histogram.stdDev must beCloseTo(0.0, 0.0)
histogram.stdDev.must(be(approximately(0.0, 0.0)))
}

@test def `calculates percentiles` = {
val percentiles = histogram.percentiles(0.5, 0.75, 0.99)

percentiles(0) must beCloseTo(0.0, 0.01)
percentiles(1) must beCloseTo(0.0, 0.01)
percentiles(2) must beCloseTo(0.0, 0.01)
percentiles(0).must(be(approximately(0.0, 0.01)))
percentiles(1).must(be(approximately(0.0, 0.01)))
percentiles(2).must(be(approximately(0.0, 0.01)))
}

@test def `has no values` = {
histogram.values.toList must beEmpty
histogram.values.toList.must(be(empty))
}
}

Expand All @@ -48,35 +48,35 @@ class HistogramMetricSpec extends Spec {
(1 to 10000).foreach(histogram.update)

@test def `has a count of 10000` = {
histogram.count must beEqualTo(10000)
histogram.count.must(be(10000))
}

@test def `has a max value of 10000` = {
histogram.max must beEqualTo(10000)
histogram.max.must(be(10000))
}

@test def `has a min value of 1` = {
histogram.min must beEqualTo(1)
histogram.min.must(be(1))
}

@test def `has a mean value of 5000.5` = {
histogram.mean must beCloseTo(5000.5, 0.01)
histogram.mean.must(be(approximately(5000.5, 0.01)))
}

@test def `has a standard deviation of X` = {
histogram.stdDev must beCloseTo(2886.89, 0.1)
histogram.stdDev.must(be(approximately(2886.89, 0.1)))
}

@test def `calculates percentiles` = {
val percentiles = histogram.percentiles(0.5, 0.75, 0.99)

percentiles(0) must beCloseTo(5000.5, 0.01)
percentiles(1) must beCloseTo(7500.75, 0.01)
percentiles(2) must beCloseTo(9900.99, 0.01)
percentiles(0).must(be(approximately(5000.5, 0.01)))
percentiles(1).must(be(approximately(7500.75, 0.01)))
percentiles(2).must(be(approximately(9900.99, 0.01)))
}

@test def `has 10000 values` = {
histogram.values.toList must beEqualTo((1 to 10000).toList)
histogram.values.toList.must(be((1 to 10000).map { java.lang.Long.valueOf(_) }.toList))
}
}

Expand Down
Expand Up @@ -10,11 +10,11 @@ class MeterMetricSpec extends Spec {
val meter = MeterMetric.newMeter("thangs", TimeUnit.SECONDS)

@test def `has a count of zero` = {
meter.count must beEqualTo(0)
meter.count.must(be(0))
}

@test def `has a mean rate of 0 events/sec` = {
meter.meanRate must beEqualTo(0.0)
meter.meanRate.must(be(0.0))
}
}

Expand All @@ -23,7 +23,7 @@ class MeterMetricSpec extends Spec {
meter.mark(3)

@test def `has a count of three` = {
meter.count must beEqualTo(3)
meter.count.must(be(3))
}
}
}
Expand Up @@ -11,60 +11,60 @@ class TimerMetricSpec extends Spec {
val timer = new TimerMetric(TimeUnit.MILLISECONDS, TimeUnit.SECONDS)

@test def `has a duration unit` = {
timer.durationUnit must be(TimeUnit.MILLISECONDS)
timer.durationUnit.must(be(TimeUnit.MILLISECONDS))
}

@test def `has a rate unit` = {
timer.rateUnit must be(TimeUnit.SECONDS)
timer.rateUnit.must(be(TimeUnit.SECONDS))
}

@test def `has a max of zero` = {
timer.max must beCloseTo(0.0, 0.001)
timer.max.must(be(approximately(0.0, 0.001)))
}

@test def `has a min of zero` = {
timer.min must beCloseTo(0.0, 0.001)
timer.min.must(be(approximately(0.0, 0.001)))
}

@test def `has a mean of zero` = {
timer.mean must beCloseTo(0.0, 0.001)
timer.mean.must(be(approximately(0.0, 0.001)))
}

@test def `has a count of zero` = {
timer.count must beEqualTo(0)
timer.count.must(be(0))
}

@test def `has a standard deviation of zero` = {
timer.stdDev must beCloseTo(0.0, 0.001)
timer.stdDev.must(be(approximately(0.0, 0.001)))
}

@test def `has a median/p95/p98/p99/p999 of zero` = {
val Array(median, p95, p98, p99, p999) = timer.percentiles(0.5, 0.95, 0.98, 0.99, 0.999)
median must beCloseTo(0.0, 0.001)
p95 must beCloseTo(0.0, 0.001)
p98 must beCloseTo(0.0, 0.001)
p99 must beCloseTo(0.0, 0.001)
p999 must beCloseTo(0.0, 0.001)
median.must(be(approximately(0.0, 0.001)))
p95.must(be(approximately(0.0, 0.001)))
p98.must(be(approximately(0.0, 0.001)))
p99.must(be(approximately(0.0, 0.001)))
p999.must(be(approximately(0.0, 0.001)))
}

@test def `has a mean rate of zero` = {
timer.meanRate must beCloseTo(0.0, 0.001)
timer.meanRate.must(be(approximately(0.0, 0.001)))
}

@test def `has a one-minute rate of zero` = {
timer.oneMinuteRate must beCloseTo(0.0, 0.001)
timer.oneMinuteRate.must(be(approximately(0.0, 0.001)))
}

@test def `has a five-minute rate of zero` = {
timer.fiveMinuteRate must beCloseTo(0.0, 0.001)
timer.fiveMinuteRate.must(be(approximately(0.0, 0.001)))
}

@test def `has a fifteen-minute rate of zero` = {
timer.fifteenMinuteRate must beCloseTo(0.0, 0.001)
timer.fifteenMinuteRate.must(be(approximately(0.0, 0.001)))
}

@test def `has no values` = {
timer.values.toList must beEmpty
timer.values.toList.must(be(empty))
}
}

Expand All @@ -77,36 +77,36 @@ class TimerMetricSpec extends Spec {
timer.update(40, TimeUnit.MILLISECONDS)

@test def `records the count` = {
timer.count must beEqualTo(5)
timer.count.must(be(5))
}

@test def `calculates the minimum duration` = {
timer.min must beCloseTo(10.0, 0.001)
timer.min.must(be(approximately(10.0, 0.001)))
}

@test def `calculates the maximum duration` = {
timer.max must beCloseTo(40.0, 0.001)
timer.max.must(be(approximately(40.0, 0.001)))
}

@test def `calculates the mean duration` = {
timer.mean must beCloseTo(24.0, 0.001)
timer.mean.must(be(approximately(24.0, 0.001)))
}

@test def `calculates the standard deviation` = {
timer.stdDev must beCloseTo(11.401, 0.001)
timer.stdDev.must(be(approximately(11.401, 0.001)))
}

@test def `calculates the median/p95/p98/p99/p999` = {
val Array(median, p95, p98, p99, p999) = timer.percentiles(0.5, 0.95, 0.98, 0.99, 0.999)
median must beCloseTo(20.0, 0.001)
p95 must beCloseTo(40.0, 0.001)
p98 must beCloseTo(40.0, 0.001)
p99 must beCloseTo(40.0, 0.001)
p999 must beCloseTo(40.0, 0.001)
median.must(be(approximately(20.0, 0.001)))
p95.must(be(approximately(40.0, 0.001)))
p98.must(be(approximately(40.0, 0.001)))
p99.must(be(approximately(40.0, 0.001)))
p999.must(be(approximately(40.0, 0.001)))
}

@test def `has a series of values` = {
timer.values.toSet must beEqualTo(Set(10, 20, 20, 30, 40))
timer.values.toSet.must(be(Set[java.lang.Double](10, 20, 20, 30, 40)))
}
}

Expand All @@ -116,23 +116,25 @@ class TimerMetricSpec extends Spec {
timer.update(0, TimeUnit.NANOSECONDS)

@test def `calculates the standard deviation without overflowing` = {
timer.stdDev must beCloseTo(75485.05, 0.01)
timer.stdDev.must(be(approximately(75485.05, 0.01)))
}
}

class `Timing Callable instances` {
val timer = new TimerMetric(TimeUnit.MILLISECONDS, TimeUnit.SECONDS)

@test def `records the duration of the Callable#call()` = {
time must eventually(beCloseTo(50.0, 2))
eventually {
time
}.must(be(approximately(50.0, 2)))
}

@test def `returns the result of the callable` = {
timer.time(new Callable[String] {
def call = {
"woo"
}
}) must beEqualTo("woo")
}).must(be("woo"))
}

private def time = {
Expand Down

0 comments on commit 953a93b

Please sign in to comment.