Skip to content

Releases: HdrHistogram/HdrHistogram.NET

RecordScope

29 Sep 02:25
Compare
Choose a tag to compare

Adds support to record a scope of code. Leveraging the using/IDisposable pattern a scope block of code can be measured without using a Lambda/Delegate/Method.

using(recorder.RecordScope())
{
    //Code to be recorded goes here
}

This has two benefits.

  1. Avoids compiler warnings about captured variables with in lambdas for code like recorder.Record(()=>MyMethod(myLocalVariable));
  2. Allows the async/await pattern to be used e.g.
using(recorder.RecordScope())
{
    await DoAsync();
}

Net Standard

20 Jun 02:12
Compare
Choose a tag to compare

This major release allows for cross platform support by way of implementing Net Standard 1.3. There is still support for .NET 4.5 for those that have not moved to tooling that supports Net Standard yet.

Bug fix

11 Jan 00:21
Compare
Choose a tag to compare

This release is just a bug fix from #39.

Concurrent Reads and Writes

02 Sep 07:21
Compare
Choose a tag to compare

This release features support for thread safe reading and writing of histogram values.

The concurrent implementations of the histograms (LongConcurrentHistogram & IntConcurrentHistogram) allow writing to a single histogram from multiple threads. This comes at a performance penalty of about 4x cost of a write.

The Recorder allows thread safe reading by allowing a consumer to rotate the underlying histogram and reading from a snapshot. This is useful for serializing histograms to disk in real time. The Recorder adds about a 2x cost to a write.

If performance of a write is of a concern, then do ensure that you choose the best Histogram implementation for your purposes. Your platform choice (x86 vs x64), and the JIT you use (Legacy vs RyuJit) can tend to favour certain implementations.Also dedicating a histogram per thread can be a useful way to avoid the extra cost of the concurrent implementations.

To help with choosing the best solution for you, the HistogramFactory is a new feature that offers a fluent syntax to create a Histogram implementation or Recorder instance. e.g. Creating an IntHistogram with default values can now be done with the following code.

var histogram = HistogramFactory
                .With32BitBucketSize()                  //IntHistogram
                .Create();

Alternatively if you wanted thread safe reads and write and wanted to fully define the settings for a LongHistogram you could use the following code.

var recorder = HistogramFactory
                .With64BitBucketSize()                  //LongHistogram
                .WithValuesFrom(1)                      //Default value
                .WithValuesUpTo(TimeStamp.Minutes(10))  //Default value
                .WithPrecisionOf(3)                     //Default value
                .WithThreadSafeWrites()                 //Switches internal imp to concurrent version i.e. LongConcurrentHistogram
                .WithThreadSafeReads()                  //returns a Recorder that wraps the LongConcurrentHistogram
                .Create();