{"id":13648760,"url":"https://github.com/llogiq/flamer","last_synced_at":"2025-05-15T12:06:43.379Z","repository":{"id":8616577,"uuid":"58586822","full_name":"llogiq/flamer","owner":"llogiq","description":"A compiler plugin to insert flame calls","archived":false,"fork":false,"pushed_at":"2023-04-13T13:39:41.000Z","size":4393,"stargazers_count":382,"open_issues_count":8,"forks_count":21,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-14T22:20:10.462Z","etag":null,"topics":["flamegraphs","hacktoberfest","instrumentation","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/llogiq.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}},"created_at":"2016-05-11T22:25:58.000Z","updated_at":"2025-03-29T12:29:48.000Z","dependencies_parsed_at":"2024-01-14T11:25:30.476Z","dependency_job_id":null,"html_url":"https://github.com/llogiq/flamer","commit_stats":{"total_commits":165,"total_committers":21,"mean_commits":7.857142857142857,"dds":0.6787878787878787,"last_synced_commit":"8c8f17f30ef03de7c0b25efff4177939b280857a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llogiq%2Fflamer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llogiq%2Fflamer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llogiq%2Fflamer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llogiq%2Fflamer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/llogiq","download_url":"https://codeload.github.com/llogiq/flamer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337613,"owners_count":22054253,"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":["flamegraphs","hacktoberfest","instrumentation","rust"],"created_at":"2024-08-02T01:04:30.987Z","updated_at":"2025-05-15T12:06:38.364Z","avatar_url":"https://github.com/llogiq.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"A proc macro to insert appropriate `flame::start_guard(_)` calls (for use with\n[flame](https://github.com/TyOverby/flame))\n\n[![Build Status](https://travis-ci.org/llogiq/flamer.svg)](https://travis-ci.org/llogiq/flamer)\n[![Current Version](https://img.shields.io/crates/v/flamer.svg)](https://crates.io/crates/flamer)\n[![Docs](https://docs.rs/flamer/badge.svg)](https://docs.rs/flamer)\n![Supported Rust Versions](https://img.shields.io/badge/rustc-1.30+-yellow.svg)\n\n**This proc macro requires Rust 1.30.**\nBecause flamer is a proc macro attribute, it uses APIs stabilized in Rust 1.30.\n\n## Usage:\n\nIn your Cargo.toml add `flame` and `flamer` to your dependencies:\n\n```toml\n[dependencies]\nflame = \"0.2.2\"\nflamer = \"0.5\"\n```\n\nThen in your crate root, add the following:\n\n```rust\nextern crate flame;\n#[macro_use] extern crate flamer;\n\n#[flame]\n// The item to apply `flame` to goes here.\n```\n\nUnfortunately, currently stable Rust doesn't allow custom attributes on modules.\nTo use `#[flame]` on modules you need a nightly Rust with\n`#![feature(proc_macro_hygiene)]` in the crate root\n([related issue](https://github.com/rust-lang/rust/issues/54727)):\n\n```rust\n#![feature(proc_macro_hygiene)]\n\nextern crate flame;\n#[macro_use] extern crate flamer;\n\n#[flame]\nmod flamed_module { .. }\n```\n\nYou may also opt for an *optional dependency*. In that case your Cargo.toml should have:\n\n```toml\n[dependencies]\nflame = { version = \"0.2.2\", optional = true }\nflamer = { version = \"0.3\", optional = true }\n\n[features]\ndefault = []\nflame_it = [\"flame\", \"flamer\"]\n```\n\nAnd your crate root should contain:\n\n```rust\n#[cfg(feature = \"flame_it\")]\nextern crate flame;\n#[cfg(feature = \"flame_it\")]\n#[macro_use] extern crate flamer;\n\n// as well as the following instead of `#[flame]`\n#[cfg_attr(feature = \"flame_it\", flame)]\n// The item to apply `flame` to goes here.\n```\n\nFor nightly module support, also add\n`#![cfg_attr(feature = \"flame_it\", feature(proc_macro_hygiene))]` in the crate\nroot:\n\n```rust\n#![cfg_attr(feature = \"flame_it\", feature(proc_macro_hygiene))]\n\n#[cfg(feature = \"flame_it\")]\nextern crate flame;\n#[cfg(feature = \"flame_it\")]\n#[macro_use] extern crate flamer;\n\n// as well as the following instead of `#[flame]`\n#[cfg_attr(feature = \"flame_it\", flame)]\nmod flamed_module { .. }\n```\n\nYou should then be able to annotate every item (alas, currently not the whole\ncrate; see the\n[custom inner attribute](https://github.com/rust-lang/rust/issues/54726) issue\nfor more details) with `#[flame]` annotations.\nYou can also use `#[noflame]` annotations to disable instrumentations for\nsubitems of `#[flame]`d items. Note that this only instruments the annotated\nmethods, it does not print out the results.\n\nThe `flame` annotation can also take an optional parameter specifying a string\nto prefix to enclosed method names.\nThis is especially useful when annotating multiple methods with the same name,\nbut in different modules.\n\n```rust\n#[flame(\"prefix\")]\nfn method_name() {\n    //The corresponding block on the flamegraph will be named \"prefix::method_name\"\n}\n```\n\n## Full Example\n```rust\nuse std::fs::File;\n\nuse flame as f;\nuse flamer::flame;\n\n#[flame]\nfn make_vec(size: usize) -\u003e Vec\u003cu32\u003e {\n    // using the original lib is still possible\n    let mut res = f::span_of(\"vec init\", || vec![0_u32; size]);\n    for x in 0..size {\n        res[x] = ((x + 10)/3) as u32;\n    }\n    let mut waste_time = 0;\n    for i in 0..size*10 {\n        waste_time += i\n    }\n    res\n}\n#[flame]\nfn more_computing(i: usize) {\n    for x in 0..(i * 100) {\n        let mut v = make_vec(x);\n        let x = Vec::from(\u0026v[..]);\n        for i in 0..v.len() {\n            let flip = (v.len() - 1) - i as usize;\n            v[i] = x[flip];\n        }\n    }\n}\n#[flame]\nfn some_computation() {\n    for i in 0..15 {\n        more_computing(i);\n    }\n}\n\n#[flame]\nfn main() {\n    some_computation();\n    // in order to create the flamegraph you must call one of the\n    // flame::dump_* functions.\n    f::dump_html(File::create(\"flamegraph.html\").unwrap()).unwrap();\n}\n```\n![flamegraph](./flamegraph.png \"Flamegraph example\")\n\nRefer to [flame's documentation](https://docs.rs/flame) to see how output works.\n\nLicense: Apache 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllogiq%2Fflamer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllogiq%2Fflamer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllogiq%2Fflamer/lists"}