@@ -155,16 +155,18 @@ def test_get_cpl_mem_usage(self, isfile):
155
155
def test_read_baseline_file_multi_line (self ):
156
156
with mock .patch (
157
157
"builtins.open" ,
158
- mock .mock_open (read_data = "#comment about data\n 1000.0\n 2000.0\n " ),
158
+ mock .mock_open (
159
+ read_data = "sha:1df0 date:2023 1000.0\n sha:3b05 date:2023 2000.0"
160
+ ),
159
161
) as mock_file :
160
162
baseline = performance .read_baseline_file ("/tmp/cpl-mem.log" )
161
163
162
164
mock_file .assert_called_with ("/tmp/cpl-mem.log" )
163
- assert baseline == "1000.0 \n 2000 .0"
165
+ assert baseline == "2000 .0"
164
166
165
167
def test_read_baseline_file_content (self ):
166
168
with mock .patch (
167
- "builtins.open" , mock .mock_open (read_data = "1000.0" )
169
+ "builtins.open" , mock .mock_open (read_data = "sha:1df0 date:2023 1000.0" )
168
170
) as mock_file :
169
171
baseline = performance .read_baseline_file ("/tmp/cpl-mem.log" )
170
172
@@ -176,14 +178,12 @@ def test_read_baseline_file(self):
176
178
baseline = performance .read_baseline_file ("/tmp/cpl-mem.log" )
177
179
178
180
mock_file .assert_called_with ("/tmp/cpl-mem.log" )
179
- assert baseline == ""
180
181
181
182
def test_write_baseline_file (self ):
182
183
with mock .patch ("builtins.open" , mock .mock_open ()) as mock_file :
183
184
performance .write_baseline_file ("/tmp/cpl-tput.log" , "1000" )
184
185
185
- mock_file .assert_called_with ("/tmp/cpl-tput.log" , "w" )
186
- mock_file .return_value .write .assert_called_with ("1000" )
186
+ mock_file .assert_called_with ("/tmp/cpl-tput.log" , "a" )
187
187
188
188
@mock .patch ("CIME.baselines.performance.get_cpl_throughput" )
189
189
@mock .patch ("CIME.baselines.performance.get_latest_cpl_logs" )
@@ -368,7 +368,7 @@ def test_perf_compare_throughput_baseline_no_tolerance(
368
368
assert below_tolerance
369
369
assert (
370
370
comment
371
- == "TPUTCOMP: Computation time changed by -0.80% relative to baseline "
371
+ == "TPUTCOMP: Throughput changed by -0.80%: baseline=500.000 sypd, tolerance=10%, current=504.000 sypd "
372
372
)
373
373
374
374
@mock .patch ("CIME.baselines.performance._perf_get_throughput" )
@@ -399,7 +399,8 @@ def test_perf_compare_throughput_baseline_above_threshold(
399
399
400
400
assert not below_tolerance
401
401
assert (
402
- comment == "Error: TPUTCOMP: Computation time increase > 5% from baseline"
402
+ comment
403
+ == "Error: TPUTCOMP: Throughput changed by 49.60%: baseline=1000.000 sypd, tolerance=5%, current=504.000 sypd"
403
404
)
404
405
405
406
@mock .patch ("CIME.baselines.performance._perf_get_throughput" )
@@ -431,7 +432,7 @@ def test_perf_compare_throughput_baseline(
431
432
assert below_tolerance
432
433
assert (
433
434
comment
434
- == "TPUTCOMP: Computation time changed by -0.80% relative to baseline "
435
+ == "TPUTCOMP: Throughput changed by -0.80%: baseline=500.000 sypd, tolerance=5%, current=504.000 sypd "
435
436
)
436
437
437
438
@mock .patch ("CIME.baselines.performance.get_cpl_mem_usage" )
@@ -466,7 +467,7 @@ def test_perf_compare_memory_baseline_no_baseline(
466
467
assert below_tolerance
467
468
assert (
468
469
comment
469
- == "MEMCOMP: Memory usage highwater has changed by 0.00% relative to baseline "
470
+ == "MEMCOMP: Memory usage highwater changed by 0.00%: baseline=0.000 MB, tolerance=5%, current=1003.000 MB "
470
471
)
471
472
472
473
@mock .patch ("CIME.baselines.performance.get_cpl_mem_usage" )
@@ -557,7 +558,7 @@ def test_perf_compare_memory_baseline_no_tolerance(
557
558
assert below_tolerance
558
559
assert (
559
560
comment
560
- == "MEMCOMP: Memory usage highwater has changed by 0.30% relative to baseline "
561
+ == "MEMCOMP: Memory usage highwater changed by 0.30%: baseline=1000.000 MB, tolerance=10%, current=1003.000 MB "
561
562
)
562
563
563
564
@mock .patch ("CIME.baselines.performance.get_cpl_mem_usage" )
@@ -592,7 +593,7 @@ def test_perf_compare_memory_baseline_above_threshold(
592
593
assert not below_tolerance
593
594
assert (
594
595
comment
595
- == "Error: Memory usage increase >5% from baseline's 1000.000000 to 2003.000000 "
596
+ == "Error: MEMCOMP: Memory usage highwater changed by 100.30%: baseline= 1000.000 MB, tolerance=5%, current= 2003.000 MB "
596
597
)
597
598
598
599
@mock .patch ("CIME.baselines.performance.get_cpl_mem_usage" )
@@ -627,7 +628,7 @@ def test_perf_compare_memory_baseline(
627
628
assert below_tolerance
628
629
assert (
629
630
comment
630
- == "MEMCOMP: Memory usage highwater has changed by 0.30% relative to baseline "
631
+ == "MEMCOMP: Memory usage highwater changed by 0.30%: baseline=1000.000 MB, tolerance=5%, current=1003.000 MB "
631
632
)
632
633
633
634
def test_get_latest_cpl_logs_found_multiple (self ):
0 commit comments