#timing #profiling #proc-macro #execution-time #measure-time

macro code-timing-macros

Macros for easily measuring execution time of various code pieces

5 releases

0.0.5 Oct 23, 2024
0.0.4 Oct 22, 2024
0.0.3 Sep 5, 2024
0.0.2 Sep 4, 2024
0.0.1 Sep 3, 2024

#933 in Development tools

Download history 127/week @ 2024-08-28 272/week @ 2024-09-04 2/week @ 2024-09-11 5/week @ 2024-09-18 4/week @ 2024-10-09 154/week @ 2024-10-16 215/week @ 2024-10-23 5/week @ 2024-10-30 8/week @ 2024-11-06 5/week @ 2024-11-20 292/week @ 2024-11-27 140/week @ 2024-12-04 87/week @ 2024-12-11

524 downloads per month

Apache-2.0

9KB
76 lines

TestLintCrates.io Version

code-timing-macros!

This crate aims to provide useful, easy to use macros to measure the time taken to execute some code. At present, this is alpha quality, and subject to changes.

Contributions welcomed!

Macros:

  • Adding #[time_function] to a function causes the program to print how long a function took to run when it's finished.
  • Use time_snippet!() to report the timing for a snippet (or block) of code.

Capabilities:

  • Works on functions and code blocks with or without a return.
  • Async functions and code blocks tested and seem to work. Please report any issues.
  • Const functions won't work since the contents of the function won't be determinable at compile time.

Features

The following crate features are available:

  • release: by default, the macros will not modify the code for release builds. This feature prevents that, so release builds will report execution time.
  • tracing: by default, the macros will print elapsed time information to standard output, but this feature instead sends information to the log using the tracing crate.

Examples

Dependencies

~230–760KB
~17K SLoC