| 1 | import benchmark |
| 2 | |
| 3 | fn main() { |
| 4 | max_iterations := arguments()[1] or { '1_000_000' }.int() |
| 5 | assert max_iterations > 0 |
| 6 | mut m := { |
| 7 | 123: 456 |
| 8 | 789: 321 |
| 9 | } |
| 10 | mut volatile sum := u64(0) |
| 11 | mut b := benchmark.start() |
| 12 | for i in 0 .. max_iterations { |
| 13 | m.clear() |
| 14 | m[i] = i * 2 |
| 15 | sum += u64(m.len) |
| 16 | } |
| 17 | assert m.len == 1 |
| 18 | b.measure('m.clear(), iterations: ${max_iterations}, sum: ${sum}') |
| 19 | } |
| 20 |