{"id":18443264,"url":"https://github.com/jbreitbart/criterion-perf-events","last_synced_at":"2025-04-09T20:05:57.827Z","repository":{"id":43323637,"uuid":"260688577","full_name":"jbreitbart/criterion-perf-events","owner":"jbreitbart","description":"A plugin for Criterion.rs to measure Linux perf events.","archived":false,"fork":false,"pushed_at":"2023-09-04T13:22:36.000Z","size":19,"stargazers_count":42,"open_issues_count":6,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T20:05:53.675Z","etag":null,"topics":["benchmarking","performance-analysis","performance-testing","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jbreitbart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-05-02T13:05:03.000Z","updated_at":"2025-02-06T13:59:12.000Z","dependencies_parsed_at":"2024-01-07T06:16:40.690Z","dependency_job_id":"d70bf656-8497-4e10-a3d0-240a05350fbc","html_url":"https://github.com/jbreitbart/criterion-perf-events","commit_stats":{"total_commits":26,"total_committers":7,"mean_commits":"3.7142857142857144","dds":0.5769230769230769,"last_synced_commit":"dc41c6c5ff52b83d9ab08805e892741e8960d812"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbreitbart%2Fcriterion-perf-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbreitbart%2Fcriterion-perf-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbreitbart%2Fcriterion-perf-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbreitbart%2Fcriterion-perf-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbreitbart","download_url":"https://codeload.github.com/jbreitbart/criterion-perf-events/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmarking","performance-analysis","performance-testing","rust"],"created_at":"2024-11-06T06:46:48.687Z","updated_at":"2025-04-09T20:05:57.806Z","avatar_url":"https://github.com/jbreitbart.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Criterion-perf-events\n\nThis is a measurement plugin for [Criterion.rs](https://github.com/bheisler/criterion.rs) to measure events of the Linux perf interface.\n\n## Supported Events\n\nCriterion-perf-events uses the [`perfcnt`](https://gz.github.io/rust-perfcnt/perfcnt/index.html) crate and supports events provided by this crate. If you are interested in more details, please take a look at the events listed here:\n\n* [Hardware events](https://gz.github.io/rust-perfcnt/perfcnt/linux/enum.HardwareEventType.html)\n* [Software events](https://gz.github.io/rust-perfcnt/perfcnt/linux/enum.SoftwareEventType.html)\n* [Perf events](https://gz.github.io/rust-perfcnt/perfcnt/linux/enum.Event.html)\n* [Raw Intel events](https://gz.github.io/rust-perfcnt/x86/perfcnt/intel/description/struct.IntelPerformanceCounterDescription.html)\n\n## Troubleshooting\n\nIf you get a \"Permission denied\" error, update `perf_event_paranoid`:\n```\nsudo sh -c 'echo 1 \u003e/proc/sys/kernel/perf_event_paranoid'\n```\nFor further details please take a look at the following [link](https://superuser.com/questions/980632/run-perf-without-root-rights).\n\n## Example\n\nThe following code shows how to count retired instructions.\n\n```rust\nuse criterion::{criterion_group, criterion_main, BenchmarkId, black_box, Criterion};\nuse criterion_perf_events::Perf;\nuse perfcnt::linux::HardwareEventType as Hardware;\nuse perfcnt::linux::PerfCounterBuilderLinux as Builder;\n\nfn fibonacci_slow(n: usize) -\u003e usize {\n    match n {\n        0 =\u003e 1,\n        1 =\u003e 1,\n        n =\u003e fibonacci_slow(n - 1) + fibonacci_slow(n - 2),\n    }\n}\n\nfn bench(c: \u0026mut Criterion\u003cPerf\u003e) {\n    let mut group = c.benchmark_group(\"fibonacci\");\n\n    let fibo_arg = 30;\n    group.bench_function(BenchmarkId::new(\"slow\", fibo_arg), |b| {\n        b.iter(|| fibonacci_slow(black_box(fibo_arg)))\n    });\n\n    group.finish()\n}\n\ncriterion_group!(\n    name = instructions_bench;\n    config = Criterion::default().with_measurement(Perf::new(Builder::from_hardware_event(Hardware::Instructions)));\n    targets = bench\n);\ncriterion_main!(instructions_bench);\n```\n\nrun with:\n```\ncargo criterion\n```\nOpen `target/criterion/reports/index.html` to view detailed results with plots.\nFor all event types (`Hardware::Instructions`, `Hardware::CacheMisses`...) criterion will always report cycles as the unit.\nNote that your event type is what is being shown, not CPU cycles.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbreitbart%2Fcriterion-perf-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbreitbart%2Fcriterion-perf-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbreitbart%2Fcriterion-perf-events/lists"}