{"id":21586046,"url":"https://github.com/magiclen/benchmarking","last_synced_at":"2025-09-19T01:15:09.236Z","repository":{"id":53788438,"uuid":"190223071","full_name":"magiclen/benchmarking","owner":"magiclen","description":"This crate can be used to execute something and measure the execution time in nano seconds. It does not output anything to the screen and the filesystem.","archived":false,"fork":false,"pushed_at":"2024-05-01T13:24:45.000Z","size":44,"stargazers_count":3,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T17:55:19.309Z","etag":null,"topics":["benchmark","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magiclen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-04T14:56:47.000Z","updated_at":"2024-05-01T13:24:41.000Z","dependencies_parsed_at":"2024-05-01T14:59:56.074Z","dependency_job_id":"fdba375c-2687-4c3a-bde0-261457d11da7","html_url":"https://github.com/magiclen/benchmarking","commit_stats":{"total_commits":42,"total_committers":2,"mean_commits":21.0,"dds":0.04761904761904767,"last_synced_commit":"f171016ca4843813106901c2c167077772335b48"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fbenchmarking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fbenchmarking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fbenchmarking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fbenchmarking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magiclen","download_url":"https://codeload.github.com/magiclen/benchmarking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142903,"owners_count":21054671,"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":["benchmark","rust"],"created_at":"2024-11-24T15:12:29.904Z","updated_at":"2025-09-19T01:15:04.176Z","avatar_url":"https://github.com/magiclen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Benchmarking\n====================\n\n[![CI](https://github.com/magiclen/benchmarking/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/benchmarking/actions/workflows/ci.yml)\n\nThis crate can be used to execute something and measure the execution time. It does not output anything to screens and filesystems.\n\n## Examples\n\n```rust\nconst VEC_LENGTH: usize = 100;\n\nbenchmarking::warm_up();\n\nlet bench_result = benchmarking::measure_function(|measurer| {\n    let mut vec: Vec\u003cusize\u003e = Vec::with_capacity(VEC_LENGTH);\n\n    unsafe {\n        vec.set_len(VEC_LENGTH);\n    }\n\n    for i in 0..VEC_LENGTH {\n        measurer.measure(|| {\n            vec[i]\n        });\n    }\n\n    vec\n}).unwrap();\n\nprintln!(\"Reading a number from a vec takes {:?}!\", bench_result.elapsed());\n```\n\n```rust\nconst VEC_LENGTH: usize = 100;\n\nbenchmarking::warm_up();\n\nlet bench_result = benchmarking::measure_function(|measurer| {\n    let mut vec: Vec\u003cusize\u003e = Vec::with_capacity(VEC_LENGTH);\n\n    measurer.measure(|| {\n        for i in 0..VEC_LENGTH {\n            vec.push(i);\n        }\n    });\n\n    vec\n}).unwrap();\n\nprintln!(\"Filling 0 to 99 into a vec takes {:?}!\", bench_result.elapsed());\n```\n\n```rust\nconst VEC_LENGTH: usize = 100;\n\nbenchmarking::warm_up();\n\nlet bench_result = benchmarking::measure_function(|measurer| {\n    let mut vec: Vec\u003cusize\u003e = Vec::with_capacity(VEC_LENGTH);\n\n    for loop_seq in 0..VEC_LENGTH {\n        measurer.measure(|| {\n            vec.push(loop_seq);\n        });\n    }\n\n    vec\n}).unwrap();\n\nprintln!(\"Pushing a number into a vec takes {:?}!\", bench_result.elapsed());\n```\n\n```rust\nconst VEC_LENGTH: usize = 100;\n\nbenchmarking::warm_up();\n\nlet bench_result = benchmarking::measure_function_n(2, |measurers| {\n    let mut vec: Vec\u003cusize\u003e = Vec::with_capacity(VEC_LENGTH);\n\n    for i in 0..VEC_LENGTH {\n        measurers[1].measure(|| {\n            vec.push(i);\n        });\n    }\n\n    for i in 0..VEC_LENGTH {\n        measurers[0].measure(|| {\n            vec[i]\n        });\n    }\n\n    vec\n}).unwrap();\n\nprintln!(\"Reading a number from a vec takes {:?}!\", bench_result[0].elapsed());\nprintln!(\"Pushing a number into a vec takes {:?}!\", bench_result[1].elapsed());\n```\n\n* The `warm_up` and `warm_up_with_duration` functions of the `benchmarking` crate runs on one thread. To warm up all CPUs, you can use the `warm_up_multi_thread` and `warm_up_multi_thread_with_duration` functions instead.\n* The `measure_function` and `measure_function_with_times` functions of the `benchmarking` crate can execute a closure for N times. To execute it repeatly for a while instead, you can use the `bench_function` and `bench_function_with_duration` functions.\n* To execute a closure with multiple threads to measure the throughput, you can use the `multi_thread_bench_function` and `multi_thread_bench_function_with_duration` functions of the `benchmarking` crate.\n\n## Crates.io\n\nhttps://crates.io/crates/benchmarking\n\n## Documentation\n\nhttps://docs.rs/benchmarking\n\n## License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fbenchmarking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagiclen%2Fbenchmarking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fbenchmarking/lists"}