blob: 52d8fe085975f04ef80bcf6c0d312c6e59a8acbc [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="The crate provides macros, which measure the time in ms until end of scope"><meta name="keywords" content="rust, rustlang, rust-lang, measure_time"><title>measure_time - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="../crates.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../measure_time/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../measure_time/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Crate measure_time</a></h2><div class="sidebar-elems"><ul class="block"><li class="version">Version 0.8.2</li><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#modules">Modules</a></li><li><a href="#macros">Macros</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#constants">Constants</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Crate <a class="mod" href="#">measure_time</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/measure_time/lib.rs.html#1-168">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The crate provides macros, which measure the time in ms until end of scope</p>
<p>This is done by creating an object, which measures the time. The time is printed when the object is dropped.</p>
<p>The logging behaviour is the same as other log macros like info!(..)</p>
<h4 id="examples"><a href="#examples">Examples</a></h4>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>measure_time::{info_time, debug_time, trace_time, error_time, print_time};
<span class="macro">info_time!</span>(<span class="string">&quot;measure function&quot;</span>);
{
<span class="macro">debug_time!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="string">&quot;measuring block&quot;</span>);
<span class="kw">let </span><span class="kw-2">mut </span>sum = <span class="number">0</span>;
<span class="kw">for </span>el <span class="kw">in </span><span class="number">0</span>..<span class="number">50000 </span>{
sum+=el;
}
<span class="macro">println!</span>(<span class="string">&quot;{:?}&quot;</span>, sum);
}
<span class="macro">trace_time!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="string">&quot;trace&quot;</span>);
<span class="macro">print_time!</span>(<span class="string">&quot;print&quot;</span>);
<span class="macro">error_time!</span>(target: <span class="string">&quot;measure_time&quot;</span>, <span class="string">&quot;custom target&quot;</span>);
<span class="comment">// --&gt; prints &quot;yep took ...&quot;, &quot;measuring function took 0.0135ms&quot;</span></code></pre></div>
</div></details><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="mod" href="kv/index.html" title="measure_time::kv mod">kv</a></div><div class="item-right docblock-short"><strong>UNSTABLE:</strong> Structured key-value pairs.</div></div></div><h2 id="macros" class="small-section-header"><a href="#macros">Macros</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.as_debug.html" title="measure_time::as_debug macro">as_debug</a></div><div class="item-right docblock-short">Get a value from a type implementing <code>std::fmt::Debug</code>.</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.as_display.html" title="measure_time::as_display macro">as_display</a></div><div class="item-right docblock-short">Get a value from a type implementing <code>std::fmt::Display</code>.</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.as_error.html" title="measure_time::as_error macro">as_error</a></div><div class="item-right docblock-short">Get a value from an error.</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.debug.html" title="measure_time::debug macro">debug</a></div><div class="item-right docblock-short">Logs a message at the debug level.</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.debug_time.html" title="measure_time::debug_time macro">debug_time</a></div><div class="item-right docblock-short">logs the time with the debug! macro</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.error.html" title="measure_time::error macro">error</a></div><div class="item-right docblock-short">Logs a message at the error level.</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.error_time.html" title="measure_time::error_time macro">error_time</a></div><div class="item-right docblock-short">logs the time with the error! macro</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.info.html" title="measure_time::info macro">info</a></div><div class="item-right docblock-short">Logs a message at the info level.</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.info_time.html" title="measure_time::info_time macro">info_time</a></div><div class="item-right docblock-short">logs the time with the info! macro</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.log.html" title="measure_time::log macro">log</a></div><div class="item-right docblock-short">The standard logging macro.</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.log_enabled.html" title="measure_time::log_enabled macro">log_enabled</a></div><div class="item-right docblock-short">Determines if a message logged at the specified level in that module will
be logged.</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.log_time.html" title="measure_time::log_time macro">log_time</a></div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.print_time.html" title="measure_time::print_time macro">print_time</a></div><div class="item-right docblock-short">logs the time with the print! macro</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.trace.html" title="measure_time::trace macro">trace</a></div><div class="item-right docblock-short">Logs a message at the trace level.</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.trace_time.html" title="measure_time::trace_time macro">trace_time</a></div><div class="item-right docblock-short">logs the time with the trace! macro</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.warn.html" title="measure_time::warn macro">warn</a></div><div class="item-right docblock-short">Logs a message at the warn level.</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.warn_time.html" title="measure_time::warn_time macro">warn_time</a></div><div class="item-right docblock-short">logs the time with the warn! macro</div></div></div><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MeasureTime.html" title="measure_time::MeasureTime struct">MeasureTime</a></div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Metadata.html" title="measure_time::Metadata struct">Metadata</a></div><div class="item-right docblock-short">Metadata about a log message.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MetadataBuilder.html" title="measure_time::MetadataBuilder struct">MetadataBuilder</a></div><div class="item-right docblock-short">Builder for <a href="struct.Metadata.html"><code>Metadata</code></a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ParseLevelError.html" title="measure_time::ParseLevelError struct">ParseLevelError</a></div><div class="item-right docblock-short">The type returned by <a href="https://doc.rust-lang.org/std/str/trait.FromStr.html#tymethod.from_str"><code>from_str</code></a> when the string doesn’t match any of the log levels.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Record.html" title="measure_time::Record struct">Record</a></div><div class="item-right docblock-short">The “payload” of a log message.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.RecordBuilder.html" title="measure_time::RecordBuilder struct">RecordBuilder</a></div><div class="item-right docblock-short">Builder for <a href="struct.Record.html"><code>Record</code></a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.SetLoggerError.html" title="measure_time::SetLoggerError struct">SetLoggerError</a></div><div class="item-right docblock-short">The type returned by <a href="fn.set_logger.html"><code>set_logger</code></a> if <a href="fn.set_logger.html"><code>set_logger</code></a> has already been called.</div></div></div><h2 id="enums" class="small-section-header"><a href="#enums">Enums</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.Level.html" title="measure_time::Level enum">Level</a></div><div class="item-right docblock-short">An enum representing the available verbosity levels of the logger.</div></div><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.LevelFilter.html" title="measure_time::LevelFilter enum">LevelFilter</a></div><div class="item-right docblock-short">An enum representing the available verbosity level filters of the logger.</div></div></div><h2 id="constants" class="small-section-header"><a href="#constants">Constants</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="constant" href="constant.STATIC_MAX_LEVEL.html" title="measure_time::STATIC_MAX_LEVEL constant">STATIC_MAX_LEVEL</a></div><div class="item-right docblock-short">The statically resolved maximum log level.</div></div></div><h2 id="traits" class="small-section-header"><a href="#traits">Traits</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Log.html" title="measure_time::Log trait">Log</a></div><div class="item-right docblock-short">A trait encapsulating the operations required of a logger.</div></div></div><h2 id="functions" class="small-section-header"><a href="#functions">Functions</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.logger.html" title="measure_time::logger fn">logger</a></div><div class="item-right docblock-short">Returns a reference to the logger.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.max_level.html" title="measure_time::max_level fn">max_level</a></div><div class="item-right docblock-short">Returns the current maximum log level.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.set_boxed_logger.html" title="measure_time::set_boxed_logger fn">set_boxed_logger</a></div><div class="item-right docblock-short">Sets the global logger to a <code>Box&lt;Log&gt;</code>.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.set_logger.html" title="measure_time::set_logger fn">set_logger</a></div><div class="item-right docblock-short">Sets the global logger to a <code>&amp;'static Log</code>.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.set_logger_racy.html" title="measure_time::set_logger_racy fn">set_logger_racy</a><sup title="unsafe function"></sup></div><div class="item-right docblock-short">A thread-unsafe version of <a href="fn.set_logger.html"><code>set_logger</code></a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.set_max_level.html" title="measure_time::set_max_level fn">set_max_level</a></div><div class="item-right docblock-short">Sets the global maximum log level.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.set_max_level_racy.html" title="measure_time::set_max_level_racy fn">set_max_level_racy</a><sup title="unsafe function"></sup></div><div class="item-right docblock-short">A thread-unsafe version of <a href="fn.set_max_level.html"><code>set_max_level</code></a>.</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="measure_time" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>