33#
44# SPDX-License-Identifier: BSD-3-Clause
55
6- from datetime import datetime
7-
86import re
97import reframe as rfm
108import reframe .utility .sanity as sn
@@ -16,12 +14,22 @@ class HelloWorldBaseTest(rfm.RegressionTest):
1614 prgenv_flags = {}
1715 sourcepath = 'hello_world'
1816 build_system = 'SingleSource'
17+ prebuild_cmds = ['_rfm_build_time="$(date +%s%N)"' ]
18+ postbuild_cmds = [
19+ '_rfm_build_time="$(($(date +%s%N)-_rfm_build_time))"' ,
20+ 'echo "Compilations time (ns): $_rfm_build_time"'
21+ ]
1922 valid_systems = ['daint:gpu' , 'daint:mc' , 'dom:gpu' , 'dom:mc' ,
2023 'arolla:cn' , 'arolla:pn' , 'tsa:cn' , 'tsa:pn' ]
2124 valid_prog_environs = ['PrgEnv-aocc' , 'PrgEnv-cray' ,
2225 'PrgEnv-cray_classic' , 'PrgEnv-gnu' ,
2326 'PrgEnv-intel' , 'PrgEnv-pgi' ,
2427 'PrgEnv-gnu-nocuda' , 'PrgEnv-pgi-nocuda' ]
28+ reference = {
29+ '*' : {
30+ 'compilation_time' : (60 , None , 0.1 , 's' )
31+ }
32+ }
2533 exclusive_access = True
2634 maintainers = ['VH' , 'EK' ]
2735 tags = {'production' , 'craype' }
@@ -93,25 +101,10 @@ def num_ranks(match):
93101 )
94102 )
95103
96- @run_before ('performance' )
97- def capture_build_time (self ):
98- self .perf_patterns = {
99- 'compilation_time' : sn .getattr (self , 'compilation_time_seconds' )
100- }
101- self .reference = {
102- '*' : {
103- 'compilation_time' : (60 , None , 0.1 , 's' )
104- }
105- }
106-
107- @run_before ('compile' )
108- def compile_timer_start (self ):
109- self .compilation_time_seconds = datetime .now ()
110-
111- @run_after ('compile' )
112- def compile_timer_end (self ):
113- elapsed = datetime .now () - self .compilation_time_seconds
114- self .compilation_time_seconds = elapsed .total_seconds ()
104+ @performance_function ('s' )
105+ def compilation_time (self ):
106+ return sn .extractsingle (r'Compilations time \(ns\): (\d+)' ,
107+ self .build_stdout , 1 , float ) * 1.0e-9
115108
116109
117110@rfm .simple_test
0 commit comments