Expand description
§Time requirements
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()
Modules§
- prelude
- Prelude module to re-export commonly used items.
- report
- Submodule defining the structs and methods for generating a report.
- task
- Submodule defining a task to be tracked.
- time_
tracker - Submodule defining the task tracker.