pocket_watch

Package Version Hex Docs

gleam add pocket_watch@1
import gleam/io
import pocket_watch

pub fn main() {
  {
    use <- pocket_watch.simple("test 1")

    a_long()
    |> long
    |> very
    |> slow
    |> pipeline
  } // pocket_watch [test 1]: took 42.0s

  {
    let print_time = fn(label, elapsed) { io.println(label <> " took a whole " <> elapsed <> "!") }
    use <- pocket_watch.callback("test 2", print_time)

    another_very()
    slow_block_of_code()
  } // test 2 took a whole 6.9m!

  let fun = fn() { a_slow_function("with", "arguments") }
  
  pocket_watch.simple("test 3", fun) // pocket_watch [test 3]: took 800ms
}

Further documentation can be found at https://hexdocs.pm/pocket_watch.

Development

gleam run   # Run the project
gleam test  # Run the tests
Search Document