The Benchmark library provides a number of functions to help you figure out how long (both in terms of wallclock and CPU time) it takes to execute some code.
func timethis(count: Int, title: String? = nil, _ body: () throws -> Void) rethrows
Run a chunk of code several times. Results will be printed to STDOUT.
timethis(count: 3) {
// do something
}
// Output:
// 0.444793617 wallclock secs (0.308 usr + 0.004 sys = 0.312 CPU)