lap

Package Version Hex Docs

Quick’n dirty timing of your Gleam code.

gleam add lap
import gleam/int
import gleam/io
import lap

pub fn main() {
  let data = lap.start_in_milliseconds("1")

  // Some work

  let data = data |> lap.time("2")

  // Some work

  let data = data |> lap.time("3")

  data |> lap.intervals |> io.debug
  // [#("1", "2", 10), #("2", "3", 30)]

  data |> lap.sort_max |> lap.pretty_print |> io.println
  // +-------+-----+----------+
  // | Start | End | Interval |
  // +-------+-----+----------+
  // | 2     | 3   | 30       |
  // | 1     | 2   | 10       |
  // +-------+-----+----------+

  data |> lap.total_time |> int.to_string |> io.println
  // 40
}
Search Document