profiling-1.0.16/.cargo_vcs_info.json0000644000000001470000000000100131140ustar { "git": { "sha1": "0ba524064aae5b4972e6be3424a2acb316f93ba3" }, "path_in_vcs": "profiling" }profiling-1.0.16/Cargo.lock0000644000000412210000000000100110650ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "aho-corasick" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] [[package]] name = "anyhow" version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "atty" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ "hermit-abi", "libc", "winapi", ] [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bincode" version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ "serde", ] [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "libc", ] [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "env_logger" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" dependencies = [ "atty", "humantime", "log", "regex", "termcolor", ] [[package]] name = "generator" version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e" dependencies = [ "cc", "libc", "log", "rustversion", "windows", ] [[package]] name = "hermit-abi" version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] [[package]] name = "humantime" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" dependencies = [ "quick-error", ] [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "lock_api" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", ] [[package]] name = "log" version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "loom" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e045d70ddfbc984eacfa964ded019534e8f6cbf36f6410aee0ed5cefa5a9175" dependencies = [ "cfg-if", "generator", "scoped-tls", "tracing", "tracing-subscriber", ] [[package]] name = "matchers" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ "regex-automata 0.1.10", ] [[package]] name = "memchr" version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "nu-ansi-term" version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" dependencies = [ "overload", "winapi", ] [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "optick" version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7e7ab6068cdba9928db83674b18fe7aa2efbaa9920698d260ecbaf7906c6548" [[package]] name = "overload" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "parking_lot" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", "windows-targets", ] [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "proc-macro2" version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] [[package]] name = "profiling" version = "1.0.16" dependencies = [ "bincode", "env_logger", "lazy_static", "log", "optick", "profiling-procmacros", "puffin", "superluminal-perf", "tracing", "tracing-subscriber", "tracing-tracy", "tracy-client", ] [[package]] name = "profiling-procmacros" version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30" dependencies = [ "quote", "syn", ] [[package]] name = "puffin" version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9f76ad4bb049fded4e572df72cbb6381ff5d1f41f85c3a04b56e4eca287a02f" dependencies = [ "anyhow", "byteorder", "cfg-if", "once_cell", "parking_lot", ] [[package]] name = "quick-error" version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags", ] [[package]] name = "regex" version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", "regex-automata 0.4.5", "regex-syntax 0.8.2", ] [[package]] name = "regex-automata" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ "regex-syntax 0.6.29", ] [[package]] name = "regex-automata" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", "regex-syntax 0.8.2", ] [[package]] name = "regex-syntax" version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rustversion" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "scoped-tls" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "sharded-slab" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] [[package]] name = "smallvec" version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "superluminal-perf" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80ed8ddf5d2a4a849fa7dc75b3e0be740adb882fe7fee87e79584402ac9b1e60" dependencies = [ "superluminal-perf-sys", ] [[package]] name = "superluminal-perf-sys" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0342a02bcc62538822a46f54294130677f026666c2e19d078fc213b7bc07ff16" [[package]] name = "syn" version = "2.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "termcolor" version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] [[package]] name = "thread_local" version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ "cfg-if", "once_cell", ] [[package]] name = "tracing" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tracing-core" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", ] [[package]] name = "tracing-log" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ "log", "once_cell", "tracing-core", ] [[package]] name = "tracing-subscriber" version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", "once_cell", "regex", "sharded-slab", "smallvec", "thread_local", "tracing", "tracing-core", "tracing-log", ] [[package]] name = "tracing-tracy" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc775fdaf33c3dfd19dc354729e65e87914bc67dcdc390ca1210807b8bee5902" dependencies = [ "tracing-core", "tracing-subscriber", "tracy-client", ] [[package]] name = "tracy-client" version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59fb931a64ff88984f86d3e9bcd1ae8843aa7fe44dd0f8097527bc172351741d" dependencies = [ "loom", "once_cell", "tracy-client-sys", ] [[package]] name = "tracy-client-sys" version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d104d610dfa9dd154535102cc9c6164ae1fa37842bc2d9e83f9ac82b0ae0882" dependencies = [ "cc", ] [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "valuable" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" profiling-1.0.16/Cargo.toml0000644000000044540000000000100111170ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2018" rust-version = "1.60" name = "profiling" version = "1.0.16" authors = ["Philip Degarmo "] build = false exclude = [ "/examples", "/screenshots", ] autobins = false autoexamples = false autotests = false autobenches = false description = "This crate provides a very thin abstraction over other profiler crates." homepage = "https://github.com/aclysma/profiling" readme = "README.md" keywords = [ "performance", "profiling", ] categories = ["development-tools::profiling"] license = "MIT OR Apache-2.0" repository = "https://github.com/aclysma/profiling" [lib] name = "profiling" path = "src/lib.rs" [dependencies.optick] version = "1.3" optional = true [dependencies.profiling-procmacros] version = "1.0.16" optional = true [dependencies.puffin] version = "0.19" optional = true [dependencies.superluminal-perf] version = "0.1" optional = true [dependencies.tracing] version = "0.1" optional = true [dependencies.tracy-client] version = "0.17" optional = true [dev-dependencies.bincode] version = "1.3.1" [dev-dependencies.env_logger] version = "0.6" [dev-dependencies.lazy_static] version = "1" [dev-dependencies.log] version = "0.4" [dev-dependencies.tracing-subscriber] version = "0.3" [dev-dependencies.tracing-tracy] version = "0.11.3" [features] default = ["procmacros"] procmacros = ["profiling-procmacros"] profile-with-optick = [ "optick", "profiling-procmacros?/profile-with-optick", ] profile-with-puffin = [ "puffin", "profiling-procmacros?/profile-with-puffin", ] profile-with-superluminal = [ "superluminal-perf", "profiling-procmacros?/profile-with-superluminal", ] profile-with-tracing = [ "tracing", "profiling-procmacros?/profile-with-tracing", ] profile-with-tracy = [ "tracy-client", "profiling-procmacros?/profile-with-tracy", ] type-check = [] profiling-1.0.16/Cargo.toml.orig000064400000000000000000000031621046102023000145730ustar 00000000000000[package] name = "profiling" version = "1.0.16" authors = ["Philip Degarmo "] edition = "2018" description = "This crate provides a very thin abstraction over other profiler crates." license = "MIT OR Apache-2.0" readme = "../README.md" repository = "https://github.com/aclysma/profiling" homepage = "https://github.com/aclysma/profiling" keywords = ["performance", "profiling"] categories = ["development-tools::profiling"] exclude = ["/examples", "/screenshots"] rust-version = "1.60" [dependencies] puffin = { version = "0.19", optional = true } optick = { version = "1.3", optional = true } tracing = { version = "0.1", optional = true } tracy-client = { version = "0.17", optional = true } superluminal-perf = { version = "0.1", optional = true } profiling-procmacros = { version = "1.0.16", path = "../profiling-procmacros", optional = true } [dev-dependencies] bincode = "1.3.1" lazy_static = "1" log = "0.4" env_logger = "0.6" tracing-tracy = { version = "0.11.3" } tracing-subscriber = { version = "0.3" } [features] default = ["procmacros"] profile-with-puffin = ["puffin", "profiling-procmacros?/profile-with-puffin"] profile-with-optick = ["optick", "profiling-procmacros?/profile-with-optick"] profile-with-superluminal = [ "superluminal-perf", "profiling-procmacros?/profile-with-superluminal", ] profile-with-tracing = ["tracing", "profiling-procmacros?/profile-with-tracing"] profile-with-tracy = [ "tracy-client", "profiling-procmacros?/profile-with-tracy", ] type-check = [] procmacros = ["profiling-procmacros"] [[example]] name = "simple" path = "examples/simple.rs" required-features = [] profiling-1.0.16/README.md000064400000000000000000000241531046102023000131660ustar 00000000000000# profiling Provides a very thin abstraction over instrumented profiling crates like `puffin`, `optick`, `tracy`, and `superluminal-perf`. Mark up your code like this: ```rust #[profiling::function] fn some_function() { burn_time(5); for i in 0..5 { profiling::scope!("Looped Operation"); } } ``` See below for resulting visualization and more details on the exposed API. **Friendly Warning:** Some profiler backends implicitly listen on network ports immediately when the host app is launched. If this is a concern, please review the enabled profiler(s) documentation for details! ## Puffin * https://github.com/EmbarkStudios/puffin * Cross-platform * You need to call `profiling::finish_frame!()` at least once per frame * To show the flamegraph, you either need to use [`puffin_http`](`https://github.com/EmbarkStudios/puffin/tree/main/puffin_http`) and [`puffin_viewer`](`https://github.com/EmbarkStudios/puffin/tree/main/puffin_viewer`), or if you're writing an [`egui`](https://github.com/emilk/egui) app, use [`puffin_egui`](`https://github.com/EmbarkStudios/puffin/tree/main/puffin_egui`). [![Puffin](screenshots/puffin-small.png)](screenshots/puffin.png) ## Optick * https://github.com/bombomby/optick * The upstream crate only provides binaries for windows. However it could probably be made to work by building optick capture code and linking against it manually. The UI is windows only. [![Optick](screenshots/optick-small.png)](screenshots/optick.jpeg) ## Superluminal * https://superluminal.eu * Windows only [![Superluminal](screenshots/superluminal-small.png)](screenshots/superluminal.jpeg) ## Tracing * https://crates.io/crates/tracing * Cross-platform * The tracing backend injects tracing `span!()` macros that match the lifetime of the profiling macros. Tracing uses callbacks rather than inlining specific pre-determined code, so it is more flexible than profiling (at the cost of more lines of code and potentially higher overhead). This allows existing and new tracing-compatible handlers to work with profiling. ![Tracing](screenshots/tracing.png) ## Tracy * https://github.com/wolfpld/tracy * Cross-platform (windows, macOS, linux) [![Tracy](screenshots/tracy-small.png)](screenshots/tracy.jpeg) ## Usage Currently, there's just six macros: * `profiling::scope!(name: &str, [tag: &str])` * name: scopes will appear in the profiler under this name * tag: optional extra data * For maximum compatibility, you are **strongly** recommended to use literal strings for the name. Some backends require static lifetime string references and some require literal strings. * `#[profiling::function]` * procmacro placed on a function to quickly wrap it in a scope using the function name * `#[profiling::all_functions]` * procmacro placed on a struct impl block to apply `#[profiling::function]` on each function under that struct impl block * `#[profiling::skip]` * use with `#[profiling::all_functions]`, placed this procmacro on a function to avoid the action that `#[profiling::all_functions]` apply * `profiling::register_thread!([name: &str])` * name: optional, defaults to `std::thread::current().name`, or `.id` if it's unnamed * `profiling::finish_frame!()` * Many profilers have the concept of a "frame" as a unit of work. Use this to indicate where one frame ends and the next one begins. * `profiling::function_scope!([tag: &str])` * Macro that can be placed within a function to create a scope with the function name * tag: optional extra data Support for individual profilers can be turned on/off with feature flags. By default, they're all off, resulting in no dependencies or runtime code. ## Who is this for? * Authors of binaries that want to have multiple options for profiling their code, but don't want to duplicate their instrumentation once per each profiler's individual API. * Authors of libraries that would like to instrument their crate for their end-users. This crate is intended to be **TINY**. It won't support every possible usage, just the basics. I'm open to adding more things but I plan to be very selective to maintain a slim size. When enabled, using a macro produces identical code as if you used the wrapped profiling API directly. So it is completely fine to directly use a profiler's API when this abstraction doesn't support something you want to do. ## Alternatives **tracing**: `tracing` is more flexible than `profiling` but is significantly larger and has some potential runtime cost. `profiling` is only useful for instrumented profiling. Instrumentation is inserted directly into your code inline via macros as if you were using the profiler's crate directly. This results in smaller code with no additional overhead. Using profiling crates (i.e. puffin/optick/etc.) directly: * For authors of binaries, you may still need to use APIs on those crates to get started. But when instrumenting your code, `profiling::scope!("Scope Name")` inside a function or `#[profiling::function]` on a function will instrument it for all the supported profiler-specific crates. You can still use those crates directly if you want to take advantage of custom APIs they provide to surface additional data. * For authors of upstream libraries, this crate lets you implement simple instrumentation once. Hopefully this will allow the community to benefit from instrumented profiling, even if a significant amount of a codebase is made of upstream crates. ## Using from a Binary It's up to you to initialize the profiling crate of your choice (although some do not need explicit initialization and will immediately work). The examples demonstrate this for all the supported crates, but it's worth looking at the docs for the profiler you're interested in using! `profiling` re-exports the profiler crates if they are enabled, simplifying the modifications you would need to make to your Cargo.toml. Once initialized, you can mix/match the macros provided by your profiler of choice and the generic ones in this crate. For example: ```rust // This may map to something like: // - puffin::profile_scope!("Scope Name") // - optick::event!("Scope Name") // - tracing::span!(tracing::Level::INFO, "Scope Name") // - superluminal_perf::begin_event("Scope Name") profiling::scope!("Scope Name"); // This may map to something like: // - puffin::profile_scope_data!("Scope Name", "extra data") // - optick::event!("Scope Name"); optick::tag!("tag", "extra data"); // - tracing::span!(tracing::Level::INFO, "Scope Name", tag = "extra data") // - superluminal_perf::begin_event_with_data("Scope Name", "extra data", 0) profiling::scope!("Scope Name", "extra data"); ``` There is also a proc macro to decorate functions: ```rust #[profiling::function] fn my_function() { } ``` Take a look at the code for the helpful macros `register_thread!()` and `finish_frame!()`. I recommend adding features for each backend you want to use to your binary crate. This allows you to optionally compile in code to setup and configure a backend. ```toml [dependencies] profiling = "1.0" [features] profile-with-puffin = ["profiling/profile-with-puffin"] profile-with-optick = ["profiling/profile-with-optick"] profile-with-superluminal = ["profiling/profile-with-superluminal"] profile-with-tracing = ["profiling/profile-with-tracing"] profile-with-tracy = ["profiling/profile-with-tracy"] ``` * You can use the default feature to quickly/temporarily turn something on: `default = ["profile-with-optick"]` * `cargo run --features=profile-with-optick` works too! ## Using from a Library Add the profiling crate to Cargo.toml: ```toml [dependencies] profiling = "1.0" ``` Now you can instrument your library using the API exposed via the `profiling` crate. If the end-user of your library doesn't use profiling, the macros in this crate will emit no code at all. ## Feature Flags * profile-with-puffin: Enable the `puffin` crate * profile-with-optick: Enable the `optick` crate * profile-with-superluminal: Enable the `superluminal-perf` crate * profile-with-tracing: Enable the `tracing` crate. (This is just an abstraction layer - you'd want to hook it to do something!) * profile-with-tracy: Enable the `tracy-client` crate. **Only one backend can be enabled at a time!** ## Examples * simple: Shows a bare minimum requirements to do some simple instrumented profiling. Once it's running, you can connect to the process using optick/tracy/superluminal. Some of these are windows only! ``` run --example simple --features="profile-with-optick" run --example simple --features="profile-with-tracy" run --example simple --features="profile-with-puffin" run --example simple --features="profile-with-superluminal" ``` * puffin: Launches a basic app with imgui integration showing the puffin UI. This one should run everywhere that supports imgui. ``` cargo run --example puffin --features="profile-with-puffin" ``` ## MSRV This project will strive to keep a conservative MSRV, but some backends will support a lower MSRV than others. The MSRV set in this project only represents the MSRV for compiling the profiling crate with no backends enabled. As a point of reference, currently the most popular crate relying on profiling is wgpu, and their MSRV is constrained to Firefox nightly build MSRV. So the MSRV of this crate (ignoring backends) should not move faster than wgpu and firefox nightly. (See `MINIMUM_RUST_VERSION` in [`python/mozboot/mozboot/util.py`](https://searchfox.org/mozilla-central/source/python/mozboot/mozboot/util.py)) ## License Licensed under either of * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option. The examples directory contains [`NotoSans-Medium.ttf`](https://www.google.com/get/noto/), available under SIL Open Font License (OFL). ### Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT). profiling-1.0.16/src/empty_impl.rs000064400000000000000000000033651046102023000152250ustar 00000000000000/// Opens a scope. Two variants: /// - profiling::scope!(name: &str) - Opens a scope with the given name /// - profiling::scope!(name: &str, data: &str) - Opens a scope with the given name and an extra /// datafield. Details of this depend on the API, but it should be a &str. If the extra data is /// named, it will be named "tag". Some APIs support adding more data (for example, `optic::tag!`) /// /// ``` /// profiling::scope!("outer"); /// for _ in 0..10 { /// profiling::scope!("inner", format!("iteration {}").as_str()); /// } /// ``` #[macro_export] macro_rules! scope { ($name:expr) => {}; ($name:expr, $data:expr) => {}; } /// Opens a scope automatically named after the current function. /// - profiling::function_scope!() - Opens a scope with the current function name /// - profiling::function_scope!(data: &str) - Opens a scope with the current function name and an extra data field. /// /// ``` /// fn function_a(){ /// profiling::function_scope!(); /// } /// fn function_b(iteration: u32){ /// profiling::function_scope!(format!("iteration {}", iteration).as_str()); /// } /// ``` #[macro_export] macro_rules! function_scope { () => {}; ($data:expr) => {}; } /// Registers a thread with the profiler API(s). This is usually setting a name for the thread. /// Two variants: /// - register_thread!() - Tries to get the name of the thread, or an ID if no name is set /// - register_thread!(name: &str) - Registers the thread using the given name #[macro_export] macro_rules! register_thread { () => {}; ($name:expr) => {}; } /// Finishes the frame. This isn't strictly necessary for some kinds of applications but a pretty /// normal thing to track in games. #[macro_export] macro_rules! finish_frame { () => {}; } profiling-1.0.16/src/lib.rs000064400000000000000000000075741046102023000136220ustar 00000000000000// // To use this library, enable one of the feature flags. Each backend implementation provides the // exact same interface. Only one may be active at a time. // // This library itself does not require std, but if any features are enabled, the upstream crate // likely will bring in std. #![no_std] /// Proc macro for creating a scope around each function under struct impl block /// ``` /// pub struct Foo { /// // some data... /// } /// /// #[profiling::all_functions] /// impl Foo { /// pub fn do_something(&self) { /// // some code... /// } /// /// pub fn do_otherthing(&self) { /// // some code... /// } /// } /// ``` /// /// The following will generate the same code /// /// ``` /// pub struct Foo { /// // some data... /// } /// /// impl Foo { /// #[profiling::function] /// pub fn do_something(&self) { /// // some code... /// } /// /// #[profiling::function] /// pub fn do_otherthing(&self) { /// // some code... /// } /// } /// ``` #[cfg(feature = "procmacros")] pub use profiling_procmacros::all_functions; /// Proc macro for creating a scope around the function, using the name of the function for the /// scope's name /// /// This must be done as a proc macro because tracing requires a const string /// /// ``` /// #[profiling::function] /// fn my_function() { /// /// } /// ``` #[cfg(feature = "procmacros")] pub use profiling_procmacros::function; /// Proc macro to skip the auto_impl for the function /// ``` /// pub struct Foo { /// // some data... /// } /// /// #[profiling::all_functions] /// impl Foo { /// pub fn do_something(&self) { /// // some code... /// } /// /// #[profiling::skip] /// pub fn do_otherthing(&self) { /// // some code... /// } /// } /// ``` /// /// The following will generate the same code /// /// ``` /// pub struct Foo { /// // some data... /// } /// /// impl Foo { /// #[profiling::function] /// pub fn do_something(&self) { /// // some code... /// } /// /// pub fn do_otherthing(&self) { /// // some code... /// } /// } /// ``` #[cfg(feature = "procmacros")] pub use profiling_procmacros::skip; #[cfg(feature = "profile-with-puffin")] pub use puffin; #[cfg(feature = "profile-with-puffin")] mod puffin_impl; #[cfg(feature = "profile-with-puffin")] #[allow(unused_imports)] pub use puffin_impl::*; #[cfg(feature = "profile-with-optick")] pub use optick; #[cfg(feature = "profile-with-optick")] mod optick_impl; #[cfg(feature = "profile-with-optick")] #[allow(unused_imports)] pub use optick_impl::*; #[cfg(feature = "profile-with-superluminal")] pub use superluminal_perf; #[cfg(feature = "profile-with-superluminal")] mod superluminal_impl; #[cfg(feature = "profile-with-superluminal")] #[allow(unused_imports)] pub use superluminal_impl::*; #[cfg(feature = "profile-with-tracing")] pub use tracing; #[cfg(feature = "profile-with-tracing")] mod tracing_impl; #[cfg(feature = "profile-with-tracing")] #[allow(unused_imports)] pub use tracing_impl::*; #[cfg(feature = "profile-with-tracy")] pub use tracy_client; #[cfg(feature = "profile-with-tracy")] mod tracy_impl; #[cfg(feature = "profile-with-tracy")] #[allow(unused_imports)] pub use tracy_impl::*; #[cfg(feature = "type-check")] mod type_check_impl; #[cfg(feature = "type-check")] #[allow(unused_imports)] pub use type_check_impl::*; #[cfg(not(any( feature = "profile-with-puffin", feature = "profile-with-optick", feature = "profile-with-superluminal", feature = "profile-with-tracing", feature = "profile-with-tracy", feature = "type-check" )))] mod empty_impl; #[cfg(not(any( feature = "profile-with-puffin", feature = "profile-with-optick", feature = "profile-with-superluminal", feature = "profile-with-tracing", feature = "profile-with-tracy", feature = "type-check" )))] #[allow(unused_imports)] pub use empty_impl::*; profiling-1.0.16/src/optick_impl.rs000064400000000000000000000021601046102023000153500ustar 00000000000000#[macro_export] macro_rules! scope { ($name:expr) => { $crate::optick::event!($name); }; // NOTE: I've not been able to get attached data to work with optick ($name:expr, $data:expr) => { $crate::optick::event!($name); $crate::optick::tag!("tag", $data); }; } #[macro_export] macro_rules! function_scope { () => { $crate::optick::event!(); }; ($data:expr) => { $crate::optick::event!(); $crate::optick::tag!("tag", $data); }; } #[macro_export] macro_rules! register_thread { () => { let thread_name = std::thread::current() .name() .map(|x| x.to_string()) .unwrap_or_else(|| format!("Thread {:?}", std::thread::current().id())); $crate::register_thread!(&thread_name); }; ($name:expr) => { $crate::optick::register_thread($name); }; } /// Finishes the frame. This isn't strictly necessary for some kinds of applications but a pretty /// normal thing to track in games. #[macro_export] macro_rules! finish_frame { () => { $crate::optick::next_frame(); }; } profiling-1.0.16/src/puffin_impl.rs000064400000000000000000000014321046102023000153470ustar 00000000000000#[macro_export] macro_rules! scope { ($name:expr) => { $crate::puffin::profile_scope!($name); }; ($name:expr, $data:expr) => { $crate::puffin::profile_scope!($name, $data); }; } #[macro_export] macro_rules! function_scope { () => { $crate::puffin::profile_function!(); }; ($data:expr) => { $crate::puffin::profile_function!($data); }; } #[macro_export] macro_rules! register_thread { () => {}; ($name:expr) => { // puffin uses the thread name }; } /// Finishes the frame. This isn't strictly necessary for some kinds of applications but a pretty /// normal thing to track in games. #[macro_export] macro_rules! finish_frame { () => { $crate::puffin::GlobalProfiler::lock().new_frame(); }; } profiling-1.0.16/src/superluminal_impl.rs000064400000000000000000000042401046102023000166000ustar 00000000000000#[macro_export] macro_rules! scope { ($name:expr) => { let _superluminal_guard = $crate::superluminal::SuperluminalGuard::new($name); }; ($name:expr, $data:expr) => { let _superluminal_guard = $crate::superluminal::SuperluminalGuard::new_with_data($name, $data); }; } #[macro_export] macro_rules! function_scope { () => { let _function_name = { struct S; let type_name = core::any::type_name::(); &type_name[..type_name.len() - 3] }; $crate::scope!(_function_name); }; ($data:expr) => { let _function_name = { struct S; let type_name = core::any::type_name::(); &type_name[..type_name.len() - 3] }; $crate::scope!(_function_name, $data); }; } #[macro_export] macro_rules! register_thread { () => { let thread_name = std::thread::current() .name() .map(|x| x.to_string()) .unwrap_or_else(|| format!("Thread {:?}", std::thread::current().id())); $crate::register_thread!(&thread_name); }; ($name:expr) => { $crate::superluminal_perf::set_current_thread_name($name); }; } #[macro_export] macro_rules! finish_frame { () => { // superluminal does not have a frame end function }; } // // RAII wrappers to support superluminal. These are public as they need to be callable from macros // but are not intended for direct use. // #[doc(hidden)] pub mod superluminal { pub struct SuperluminalGuard; // 0xFFFFFFFF means "use default color" const DEFAULT_SUPERLUMINAL_COLOR: u32 = 0xFFFFFFFF; impl SuperluminalGuard { pub fn new(name: &str) -> Self { superluminal_perf::begin_event(name); SuperluminalGuard } pub fn new_with_data( name: &str, data: &str, ) -> Self { superluminal_perf::begin_event_with_data(name, data, DEFAULT_SUPERLUMINAL_COLOR); SuperluminalGuard } } impl Drop for SuperluminalGuard { fn drop(&mut self) { superluminal_perf::end_event(); } } } profiling-1.0.16/src/tracing_impl.rs000064400000000000000000000027261046102023000155160ustar 00000000000000#[macro_export] macro_rules! scope { ($name:expr) => { let _span = $crate::tracing::span!($crate::tracing::Level::INFO, $name); let _span_entered = _span.enter(); }; ($name:expr, $data:expr) => { let _span = $crate::tracing::span!($crate::tracing::Level::INFO, $name, tag = $data); let _span_entered = _span.enter(); }; } #[macro_export] macro_rules! function_scope { () => { let function_name = { struct S; let type_name = core::any::type_name::(); &type_name[..type_name.len() - 3] }; let _span = $crate::tracing::span!( $crate::tracing::Level::INFO, "function_scope", "{}", function_name ); let _span_entered = _span.enter(); }; ($data:expr) => { let function_name = { struct S; let type_name = core::any::type_name::(); &type_name[..type_name.len() - 3] }; let _span = $crate::tracing::span!( $crate::tracing::Level::INFO, "function_scope", tag = $data, "{}", function_name ); let _span_entered = _span.enter(); }; } #[macro_export] macro_rules! register_thread { () => {}; ($name:expr) => {}; } #[macro_export] macro_rules! finish_frame { () => { $crate::tracing::event!($crate::tracing::Level::INFO, tracy.frame_mark = true); }; } profiling-1.0.16/src/tracy_impl.rs000064400000000000000000000060511046102023000152040ustar 00000000000000#[macro_export] macro_rules! scope { // Note: literal patterns provided as an optimization since they can skip an allocation. ($name:literal) => { // Note: callstack_depth is 0 since this has significant overhead let _tracy_span = $crate::tracy_client::span!($name, 0); }; ($name:literal, $data:expr) => { // Note: callstack_depth is 0 since this has significant overhead let _tracy_span = $crate::tracy_client::span!($name, 0); _tracy_span.emit_text($data); }; ($name:expr) => { let _function_name = { struct S; let type_name = core::any::type_name::(); &type_name[..type_name.len() - 3] }; let _tracy_span = $crate::tracy_client::Client::running() .expect("scope! without a running tracy_client::Client") // Note: callstack_depth is 0 since this has significant overhead .span_alloc(Some($name), _function_name, file!(), line!(), 0); }; ($name:expr, $data:expr) => { let _function_name = { struct S; let type_name = core::any::type_name::(); &type_name[..type_name.len() - 3] }; let _tracy_span = $crate::tracy_client::Client::running() .expect("scope! without a running tracy_client::Client") // Note: callstack_depth is 0 since this has significant overhead .span_alloc(Some($name), _function_name, file!(), line!(), 0); _tracy_span.emit_text($data); }; } #[macro_export] macro_rules! function_scope { () => { let _tracy_span = $crate::tracy_client::span!(); }; ($data:expr) => { let _location = $crate::tracy_client::span_location!(); let _tracy_span = $crate::tracy_client::Client::running() .expect("function_scope! without a running tracy_client::Client") .span(_location, 0); _tracy_span.emit_text($data); }; } /// Registers a thread with the profiler API(s). This is usually setting a name for the thread. /// Two variants: /// - register_thread!() - Tries to get the name of the thread, or an ID if no name is set /// - register_thread!(name: &str) - Registers the thread using the given name #[macro_export] macro_rules! register_thread { () => { let thread_name = std::thread::current() .name() .map(|x| x.to_string()) .unwrap_or_else(|| format!("Thread {:?}", std::thread::current().id())); $crate::register_thread!(&thread_name); }; ($name:expr) => { $crate::tracy_client::Client::running() .expect("register_thread! without a running tracy_client::Client") .set_thread_name($name); }; } /// Finishes the frame. This isn't strictly necessary for some kinds of applications but a pretty /// normal thing to track in games. #[macro_export] macro_rules! finish_frame { () => { $crate::tracy_client::Client::running() .expect("finish_frame! without a running tracy_client::Client") .frame_mark(); }; } profiling-1.0.16/src/type_check_impl.rs000064400000000000000000000010501046102023000161720ustar 00000000000000// This backend is intended to force type checking #[macro_export] macro_rules! scope { ($name:expr) => { let _: &str = $name; }; ($name:expr, $data:expr) => { let _: &str = $name; let _: &str = $data; }; } #[macro_export] macro_rules! function_scope { () => {}; ($data:expr) => { let _: &str = $data; }; } #[macro_export] macro_rules! register_thread { () => {}; ($name:expr) => { let _: &str = $name; }; } #[macro_export] macro_rules! finish_frame { () => {}; }