Using MonoTime for Timing
This example demonstrates how to count time using the MonoTime
type.
import std.time.*
const count = 10000
main() {
let start = MonoTime.now()
for (_ in 0..count) {
DateTime.now()
}
let end = MonoTime.now()
let result = end - start
println("total cost: ${result.toNanoseconds()}ns")
}
Running result (subject to the actual result):
total cost: 951159ns