|
57 | 57 | @test actual == expected |
58 | 58 | end |
59 | 59 |
|
60 | | - @testset verbose=true "disable and enable timings" begin |
| 60 | + @testset verbose=true "disable and enable timings using disable_debug_timings and enable_debug_timings" begin |
61 | 61 | # Start with empty timer output |
62 | 62 | TrixiBase.TimerOutputs.reset_timer!(timer()) |
63 | 63 |
|
|
68 | 68 | @trixi_timeit timer() "test timer" sin(0.0) |
69 | 69 | @trixi_timeit timer() "test timer" sin(0.0) |
70 | 70 |
|
71 | | - # Disable timings |
| 71 | + # Enable timings |
72 | 72 | enable_debug_timings() |
73 | 73 |
|
74 | 74 | # This timing should be counted |
75 | 75 | @trixi_timeit timer() "test timer 2" sin(0.0) |
76 | 76 |
|
77 | | - println(timer()) |
| 77 | + timer_output = """ |
| 78 | + ───────────────────────────────────────────────────────────────────────── |
| 79 | + Time Allocations |
| 80 | + ─────────────────────── ──────────────────────── |
| 81 | + Tot / % measured: 23.7ms / 0.0% 1.00MiB / 0.0% |
| 82 | +
|
| 83 | + Section ncalls time %tot avg alloc %tot avg |
| 84 | + ───────────────────────────────────────────────────────────────────────── |
| 85 | + test timer 2 1 875ns 100.0% 875ns 48.0B 100.0% 48.0B |
| 86 | + ───────────────────────────────────────────────────────────────────────── |
| 87 | + """ |
| 88 | + # Remove "Tot / % measured" line and trailing white spaces and replace |
| 89 | + # the "test timer" line (but don't remove it, we want to check that it's there). |
| 90 | + expected = replace(timer_output, r"Tot / % measured: .*" => "", |
| 91 | + r"\s+\n" => "\n", |
| 92 | + r"test timer 2 1 .*B\n" => "test timer 2 1") |
| 93 | + actual = replace(repr(timer()) * "\n", r"Tot / % measured: .*" => "", |
| 94 | + r"\s+\n" => "\n", |
| 95 | + r"test timer 2 1 .*B\n" => "test timer 2 1") |
| 96 | + |
| 97 | + # Compare against empty timer output |
| 98 | + @test actual == expected |
| 99 | + end |
| 100 | + |
| 101 | + @testset verbose=true "disable and enable timings using disable_timer! and enable_timer!" begin |
| 102 | + # Start with empty timer output |
| 103 | + TrixiBase.TimerOutputs.reset_timer!(timer()) |
| 104 | + |
| 105 | + # Disable timer |
| 106 | + TrixiBase.TimerOutputs.disable_timer!(timer()) |
| 107 | + |
| 108 | + # These two timings should be disabled |
| 109 | + @trixi_timeit timer() "test timer" sin(0.0) |
| 110 | + @trixi_timeit timer() "test timer" sin(0.0) |
| 111 | + |
| 112 | + # Enable timer |
| 113 | + TrixiBase.TimerOutputs.enable_timer!(timer()) |
| 114 | + |
| 115 | + # This timing should be counted |
| 116 | + @trixi_timeit timer() "test timer 2" sin(0.0) |
78 | 117 |
|
79 | 118 | timer_output = """ |
80 | 119 | ───────────────────────────────────────────────────────────────────────── |
|
0 commit comments