From 05b78a3ddda292c6b118c509f8f83a999ea392ed Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Fri, 1 May 2020 15:43:43 -0400 Subject: [PATCH] add profiling feature --- Cargo.toml | 2 ++ src/lib.rs | 1 + src/main.rs | 1 + src/stylesheet.rs | 6 ++++-- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6f1bc12..30d6355 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,8 @@ nightly = [] random = ["rand"] # Option: compile to web assembly wasm = ["wasm-bindgen"] +# Option: enable features that assist in profiling (e.g. inline(never)) +profiling = [] [dev-dependencies] tempfile = "3" diff --git a/src/lib.rs b/src/lib.rs index 26b2845..75ff116 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,6 +80,7 @@ grass input.scss clippy::redundant_pub_crate, )] #![cfg_attr(feature = "nightly", feature(track_caller))] +#![cfg_attr(feature = "profiling", inline(never))] use std::iter::Iterator; diff --git a/src/main.rs b/src/main.rs index 1691a85..10d330a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,6 +21,7 @@ arg_enum! { } } +#[cfg_attr(feature = "profiling", inline(never))] fn main() -> std::io::Result<()> { let matches = App::new("grass") .version(env!("CARGO_PKG_VERSION")) diff --git a/src/stylesheet.rs b/src/stylesheet.rs index d2c8732..aff2527 100644 --- a/src/stylesheet.rs +++ b/src/stylesheet.rs @@ -71,7 +71,8 @@ impl StyleSheet { /// Ok(()) /// } /// ``` - #[inline] + #[cfg_attr(feature = "profiling", inline(never))] + #[cfg_attr(not(feature = "profiling"), inline)] #[cfg(not(feature = "wasm"))] pub fn new(input: String) -> SassResult { let mut map = CodeMap::new(); @@ -102,7 +103,8 @@ impl StyleSheet { /// Ok(()) /// } /// ``` - #[inline] + #[cfg_attr(feature = "profiling", inline(never))] + #[cfg_attr(not(feature = "profiling"), inline)] #[cfg(not(feature = "wasm"))] pub fn from_path(p: &str) -> SassResult { let mut map = CodeMap::new();