What is this?

I needed a way to time code segments from various different parts of my programs but track them with a singular list for later output. For instance, I time render code, database code, and other code during a web request then include the output in the page itself for debugging.

Example:

rust let mut stopwatch = onestop::OneDuration::new(format!("postrender#789")); some_long_task(); stopwatch.finish(); println!("It took {:?}", stopwatch.duration);

OK but...?

You could've accomplished the above with just std::time::Instant (which this code uses), but now let's use our threadsafe shared list to make it more useful:

```rust struct Service1 { timings: OneList // The other thing in this crate } struct Service2 { timings: OneList }

impl Service1 { fn dostuff(&self) -> { onestop!{(self.timings, "service1dostuff") => { assert_eq!(4, 4); }}; } }

impl Service2 { fn dostuff(&self) -> { onestop!{(self.timings, "service2dostuff") => { println!("did service2 things!"); }}; } }

// Clones of OneList are threadsafe reference-counted pointers to the original list // stored here in 'alltimings' let alltimings = OneList::::new(); let service1 = Service1 { alltimings.clone() }; let service2 = Service2 { alltimings.clone() };

service1.dostuff(); service2.dostuff();

// Both go to the same list, which you can then print out somewhere later asserteq(2, alltimings.list_copy().len()); ```

No but for real

Yes, the library is basically useless!