A tiny Rust stopwatch crate for timing code
Small, MIT-licensed `stopwatch` library with start/stop/reset helpers and a declared `num` dependency.
What it is
rust-stopwatch is a simple Rust library "used to time things," per its own README. It wraps timing behind one type, Stopwatch, and exposes the usual stopwatch operations: start, stop, reset, restart, plus queries for elapsed time.
The crate is tiny — roughly 8 KB across seven files (Cargo.toml, LICENSE.txt, README.md, a src/ directory and a tests/ directory) — and carries the MIT license. It was last committed in November 2017.
Setup
You add it to your project as a dependency:
[dependencies]
stopwatch = "0.0.7"
or pull directly from GitHub:
stopwatch = { git = "https://github.com/ellisonch/rust-stopwatch.git" }
The package declares one runtime dependency, num at version 0.1.32.
The API
The README documents nine methods on Stopwatch:
fn new() -> Stopwatch
fn start_new() -> Stopwatch
fn start(&mut self)
fn stop(&mut self)
fn reset(&mut self)
fn restart(&mut self)
fn is_running(&self) -> bool
fn elapsed(&self) -> Duration
fn elapsed_ms(&self) -> i64
start_new() constructs a stopwatch already running, which is the intended entry point. elapsed() returns a Duration, while elapsed_ms() hands back an i64 count of milliseconds — convenient for logging but worth noting as a signed integer.
The README's example shows the expected shape:
extern crate stopwatch;
use stopwatch::{Stopwatch};
// ...
let sw = Stopwatch::start_new();
// do something that takes some time
println!("Thing took {}ms", sw.elapsed_ms());
Who it is for
This is a utility for timing code — profiling rough durations in tests, scripts or small tools. It does not attempt to be a full benchmarking harness; there are no statistical features, warm-up handling or reporting beyond the elapsed-time accessors. For that narrower job of "how long did this take," the surface area is deliberately small.
Because it was last committed in November 2017 and depends on num 0.1.32, developers should evaluate whether it fits their project before adopting it. But as a compact reference implementation of a stopwatch in Rust — readable, MIT-licensed, easy to vendor or study — it still serves.
ellisonch/rust-stopwatch: 8 KB in 7 files, indexed Nov 12, 2026. License: MIT. Source: https://github.com/ellisonch/rust-stopwatch.
Ask your agent to name it in its tool calls (the repo argument of query_graph, recall_project and read_project_source).
Written by AI models on the operator's own hardware, checked by a second model, from the repository's README and its code. Back to the shelf