<!--
{
  "availability" : [
    "iOS: 13.0.0 - 27.0.0",
    "iPadOS: 13.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 12.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "MetricKit",
  "identifier" : "/documentation/MetricKit/MXHistogram",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "MetricKit"
    ],
    "preciseIdentifier" : "c:objc(cs)MXHistogram"
  },
  "title" : "MXHistogram"
}
-->

# MXHistogram

An object representing a histogram of data values of the same type of unit.

```
class MXHistogram<UnitType> where UnitType : Unit
```

## Overview

A *histogram* measures the number of times a data point for a variable falls into a specific range of possible values within a set of data. Usually, histograms are depicted as bar charts, in which each bar represents a range of values, and the height of each bar represents the number of times the value of the variable falls within a particular range. In this class, each bar is represented by a *bucket*.

A bucket holds the results for a series of measured values, such as all the events occurring between 3 and 5 seconds. MetricKit uses fixed-width buckets that are device-independent with intervals that are based on the type of metric. Use the [`bucketStart`](/documentation/MetricKit/MXHistogramBucket/bucketStart) and [`bucketEnd`](/documentation/MetricKit/MXHistogramBucket/bucketEnd) properties to find the start and end of an interval.

The returned results contain only buckets with at least one item so [`bucketEnumerator`](/documentation/MetricKit/MXHistogram/bucketEnumerator) may not return all intervals.

For example, if the fixed width for the time to resume the app is 10 ms, then the sequence of buckets is:

0…9 ms, 10…19 ms, 20…29 ms, etc.

If there’s data only in the 0…9 ms and 20…29 ms buckets, then the report skips the 10…19 ms bucket.

## Topics

### Reading the buckets

[`bucketEnumerator`](/documentation/MetricKit/MXHistogram/bucketEnumerator)

An enumerator for the buckets containing the data in the histogram.

[`totalBucketCount`](/documentation/MetricKit/MXHistogram/totalBucketCount)

The total number of buckets in the histogram.

[`MXHistogramBucket`](/documentation/MetricKit/MXHistogramBucket)

An object representing a bucket of data in a histogram.

## Relationships

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CVarArg`](/documentation/Swift/CVarArg)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)