I am trying to manually time some functions runtime in Gleam. I am using birl. However, the following timing code doesnt seem to work at all. Am I doing something wrong? (by wrong, I mean that the actually runtime of the code is much longer then the millisecond differences produced by the code below)
import birl
import birl/duration
import gleam/int
import gleam/io
import gleam/list
pub fn main() {
let times = [birl.utc_now()]
// do something
let times = times |> list.append([birl.utc_now()])
// do something
let times = times |> list.append([birl.utc_now()])
// do something
let times = times |> list.append([birl.utc_now()])
// print timing results
list.each(list.zip(list.drop(times, 1), times), fn(pair) {
let #(a, b) = pair
let duration.Duration(micro) = birl.difference(a, b)
let milli = micro / 1000
io.print(",")
io.print(milli |> int.to_string)
})
}
I am trying to manually time some functions runtime in Gleam. I am using
birl
. However, the following timing code doesnt seem to work at all. Am I doing something wrong? (by wrong, I mean that the actually runtime of the code is much longer then the millisecond differences produced by the code below)