HdrHistogram_c Documentation

repository·main·Indexed 43 days ago

https://github.com/hdrhistogram/hdrhistogram_c

A C port of the High Dynamic Range (HDR) Histogram for recording and analyzing latency distributions with high precision and low overhead. Supports 64-bit counts, various iterator types, and histogram serialization (encoding version 1.2). Includes functions for initialization via hdr_init, recording values with hdr_record_value, and printing results with hdr_percentiles_print.

Tokens
774
Snippets
2
Records
3
Agent score
5%

What's inside HdrHistogram_c

  1. HdrHistogram_c supported features

    main

    The C port provides a subset of the Java implementation's functionality.

    Supported features:

    • Standard histogram with 64-bit counts (32-bit and 16-bit counts are not supported).
    • All iterator types (all values, recorded, percentiles, linear, logarithmic).
    • Histogram serialization (encoding version 1.2, decoding 1.0-1.2).
    • Reader/writer phaser and interval recorder.

    Planned features:

    • Auto-resizing of histograms.

    Unlikely to be implemented:

    • Double histograms.
    • Atomic/Concurrent histograms.
    • 16/32 bit histograms.
  2. Initialize and record values in HdrHistogram_c

    main

    To use HdrHistogram_c, you must first initialize a histogram using hdr_init. This function sets the range and precision of the histogram. Once initialized, you can record individual values, record a single value multiple times, or record values with correction for coordinated omission. Finally, you can print the results using hdr_percentiles_print.

    #include <hdr_histogram.h>
    
    struct hdr_histogram* histogram;
    
    // Initialise the histogram
    hdr_init(
        1,  // Minimum value
        INT64_C(3600000000),  // Maximum value
        3,  // Number of significant figures
        &histogram)  // Pointer to initialise
    
    // Record value
    hdr_record_value(
        histogram,  // Histogram to record to
        value)  // Value to record
    
    // Record value n times
    hdr_record_values(
        histogram,  // Histogram to record to
        value,  // Value to record
        10)  // Record value 10 times
    
    // Record value with correction for co-ordinated omission.
    hdr_record_corrected_value(
        histogram,  // Histogram to record to
        value,  // Value to record
        1000)  // Record with expected interval of 1000.
    
    // Print out the values of the histogram
    hdr_percentiles_print(
        histogram,
        stdout,  // File to write to
        5,  // Granularity of printed values
        1.0,  // Multiplier for results
        CLASSIC);  // Format CLASSIC/CSV supported.