time_requirements

Crates.iotime_requirements
lib.rstime_requirements
version0.1.0
created_at2026-01-06 09:29:31.811317+00
updated_at2026-01-06 09:29:31.811317+00
descriptionCrate to measure time requirements of steps in your code.
homepagehttps://github.com/earth-metabolome-initiative/time_requirements
repositoryhttps://github.com/earth-metabolome-initiative/time_requirements
max_upload_size
id2025498
size49,824
Luca Cappelletti (LucaCappelletti94)

documentation

https://docs.rs/time_requirements

README

Time requirements

CI Security Audit License: MIT Codecov Crates.io Docs.rs

Simple crate to measure time requirements of steps in your code.

Within our projects, we use this tool primarily to understand which parts of the build process are slow and need to be optimized.

Usage

use std::{thread, time::Duration};
use time_requirements::prelude::*;

let mut tracker = TimeTracker::new("My Project");

// Start tracking a task
let task = Task::new("Heavy Computation");

// Simulate work
thread::sleep(Duration::from_millis(100));

// Complete the task and add it to the tracker
tracker.add_completed_task(task);

// You can also use sub-trackers for logical grouping
let mut sub_tracker = TimeTracker::new("Database Operations");
let sub_task = Task::new("Query");
// ... perform query ...
sub_tracker.add_completed_task(sub_task);

// Merge sub-tracker into the main tracker
tracker.extend(sub_tracker);

// Save the report to a file
tracker.write("report.md").unwrap();

This creates a markdown report of the time spent on tasks, which you can see an example of in report.md.

Features

  • Simple Task Tracking: Measure the duration of individual tasks.
  • Hierarchical Reporting: Use sub-trackers to group tasks logically.
  • Markdown Reports: Automatically generate readable Markdown reports including:
    • Total time spent
    • Slowest task analysis
    • Detailed table of tasks with time and percentage distributions
    • JSON export support via save()
Commit count: 6

cargo fmt