{"id":13438198,"url":"https://github.com/llogiq/flame","last_synced_at":"2025-12-12T16:45:27.247Z","repository":{"id":41454778,"uuid":"44222494","full_name":"llogiq/flame","owner":"llogiq","description":"An intrusive flamegraph profiling tool for rust.","archived":false,"fork":false,"pushed_at":"2024-02-25T08:27:13.000Z","size":924,"stargazers_count":714,"open_issues_count":14,"forks_count":29,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-13T00:46:09.987Z","etag":null,"topics":[],"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-APACHE.txt","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":"2015-10-14T03:47:43.000Z","updated_at":"2025-03-29T12:26:52.000Z","dependencies_parsed_at":"2024-06-18T19:48:22.900Z","dependency_job_id":"f8069f94-ab6f-45ec-abb5-6e6c2e1b44ee","html_url":"https://github.com/llogiq/flame","commit_stats":null,"previous_names":["tyoverby/flame"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llogiq%2Fflame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llogiq%2Fflame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llogiq%2Fflame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llogiq%2Fflame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/llogiq","download_url":"https://codeload.github.com/llogiq/flame/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650432,"owners_count":21139672,"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":[],"created_at":"2024-07-31T03:01:03.610Z","updated_at":"2025-12-12T16:45:22.210Z","avatar_url":"https://github.com/llogiq.png","language":"Rust","readme":"# FLAME\n#### A cool flamegraph library for rust\n\nFlamegraphs are a great way to view profiling information.\nAt a glance, they give you information about how much time your\nprogram spends in critical sections of your code giving you some\nmuch-needed insight into where optimizations may be needed.\n\nUnlike tools like `perf` which have the OS interrupt your running\nprogram repeatedly and reports on every function in your callstack,\nFLAME lets you choose what you want to see in the graph by adding\nperformance instrumentation to your own code.\n\nSimply use any of FLAMEs APIs to annotate the start and end of a\nblock code that you want timing information from, and FLAME will\norganize these timings hierarchically.\n\n### [Docs](https://docs.rs/flame/)\n\nHere's an example of how to use some of FLAMEs APIs:\n\n```rust\nextern crate flame;\n\nuse std::fs::File;\n\nfn main() {\n    // Manual `start` and `end`\n    flame::start(\"read file\");\n    let x = read_a_file();\n    flame::end(\"read file\");\n\n    // Time the execution of a closure.  (the result of the closure is returned)\n    let y = flame::span_of(\"database query\", || query_database());\n\n    // Time the execution of a block by creating a guard.\n    let z = {\n        let _guard = flame::start_guard(\"cpu-heavy calculation\");\n        cpu_heavy_operations_1();\n        // Notes can be used to annotate a particular instant in time.\n        flame::note(\"something interesting happened\", None);\n        cpu_heavy_operations_2()\n    };\n\n    // Dump the report to disk\n    flame::dump_html(\u0026mut File::create(\"flame-graph.html\").unwrap()).unwrap();\n    \n    // Or read and process the data yourself!\n    let spans = flame::spans();\n    \n    println!(\"{} {} {}\", x, y, z);\n}\n```\n\nAnd here's a screenshot of a flamegraph produced by `dump_html` (from a different project):\n\n![flamegraph](./resources/screenshot.png \"Flamegraph example\")\n\n### Full Example\n```rust\nuse std::fs::File;\n\nuse flame;\n\nfn make_vec(size: usize) -\u003e Vec\u003cu32\u003e {\n    // start_guard needs to drop to calculate duration.\n    let _fg = ::flame::start_guard(\"make_vec\");\n\n    let mut res = flame::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\nfn more_computing(i: usize) {\n    let _fg = ::flame::start_guard(\"more_computation\");\n\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\nfn some_computation() {\n    let _fg = ::flame::start_guard(\"some_computation\");\n\n    for i in 0..15 {\n        more_computing(i);\n    }\n}\n\n\nfn main() {\n    let _fg = ::flame::start_guard(\"main\");\n    \n    some_computation();\n    // in order to create the flamegraph you must call one of the\n    // flame::dump_* functions.\n    flame::dump_html(File::create(\"flamegraph.html\").unwrap()).unwrap();\n}\n```\n\nBelow is the resulting flamegraph.\n\n![flamegraph](./resources/flamegraph.png \"Flamegraph example\")\n\n[llogiq](https://github.com/llogiq) has created [flamer](https://github.com/llogiq/flamer),\na compiler plugin that automatically inserts FLAME instrumentation into annotated functions\nallowing you to write code like\n\n```rust\n#[flame]\nfn this_function_is_profiled() {\n    ...\n}\n```\n","funding_links":[],"categories":["Development tools","Rust","开发工具 Development tools","开发工具"],"sub_categories":["Profiling","分析 Profiling","剖析"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllogiq%2Fflame","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllogiq%2Fflame","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllogiq%2Fflame/lists"}