# perf_counters

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/diagnostics/perf_counters/

**module** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
module perf_counters
```

Counters of the work the framework does per operation: how many property
changes are raised and how many of them anybody listens to, how many
styles are evaluated and how many match, how many resources are looked
up, how many bindings and text layouts are created. The performance
designs (`docs/porting/performance/designs`) each start by reading them.

An addition of the port (DEVIATIONS.md, Diagnostics): upstream has no
counterpart. The counters exist only with the feature `perf-counters`.
Without it `perf_count!` and
`perf_count_virtual!` expand to no code, the
functions of this module have empty bodies and
[`PerfCountersSnapshot`](/docs/0.5.0/api/ferroui-base/diagnostics/perf_counters/struct-perfcounterssnapshot/) has no size; no type of the framework gains a
field either way.

The counters are per thread (the thread of the dispatcher is the one that
is measured), and counting changes no behaviour. Read them around the
measured work:

```ignore
let before = perf_counters::snapshot();
// ... the work ...
let counted = perf_counters::snapshot().since(&before);
println!("{}", counted.report_per(rows, "row"));
```

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/diagnostics/perf_counters.rs#L1)

## Contents

- [`ENABLED`](/docs/0.5.0/api/ferroui-base/diagnostics/perf_counters/constant-enabled/) — constant
- [`PerfCounter`](/docs/0.5.0/api/ferroui-base/diagnostics/perf_counters/enum-perfcounter/) — enum
- [`count`](/docs/0.5.0/api/ferroui-base/diagnostics/perf_counters/function-count/) — function
- [`add`](/docs/0.5.0/api/ferroui-base/diagnostics/perf_counters/function-add/) — function
- [`count_virtual_call`](/docs/0.5.0/api/ferroui-base/diagnostics/perf_counters/function-count_virtual_call/) — function
- [`PerfCountersSnapshot`](/docs/0.5.0/api/ferroui-base/diagnostics/perf_counters/struct-perfcounterssnapshot/) — struct
- [`snapshot`](/docs/0.5.0/api/ferroui-base/diagnostics/perf_counters/function-snapshot/) — function
- [`reset`](/docs/0.5.0/api/ferroui-base/diagnostics/perf_counters/function-reset/) — function

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
