Skip to content
← Index | Lesson 3 of 4

@benchmark

@benchmark — Measure performance

@benchmark measures execution time:

@benchmark
fn heavy_computation() -> int {
    let mut sum = 0
    for i in 0..1000000 {
        sum = sum + i
    }
    return sum
}

print(heavy_computation())
// [benchmark] heavy_computation: 12ms

Goal: Add @benchmark to a function that computes the sum from 1 to 1,000,000.

lesson-7-3.zolo
Program output

Run the code to see the output

Search Zolo

9 results

enespt-br