@@ -47,9 +47,9 @@ parser.add_argument(
4747args = parser .parse_args ()
4848
4949# Open output file if specified
50- output_file = None
50+ OUTPUT_FILE = None
5151if args .output :
52- output_file = open (args .output , "w" , encoding = "utf-8" )
52+ OUTPUT_FILE = open (args .output , "w" , encoding = "utf-8" )
5353
5454
5555def print_with_timestamp (message , file = None ):
@@ -76,37 +76,37 @@ def do_tests():
7676 - Matrix summation (np.sum)
7777 """
7878 size = 2500
79- A = np .random .rand (size , size )
80- B = np .random .rand (size , size )
79+ a = np .random .rand (size , size )
80+ b = np .random .rand (size , size )
8181
8282 # Number of iterations
8383 iterations = args .count
8484
8585 tests = [
86- ("Matrix multiplication" , lambda : np .dot (A , B )),
87- ("Matrix transposition" , lambda : np .transpose (A )),
88- ("Eigenvalue computation" , lambda : np .linalg .eigvals (A )),
89- ("Fourier transformation" , lambda : np .fft .fft (A )),
90- ("Summation" , lambda : np .sum (A )),
86+ ("Matrix multiplication" , lambda : np .dot (a , b )),
87+ ("Matrix transposition" , lambda : np .transpose (a )),
88+ ("Eigenvalue computation" , lambda : np .linalg .eigvals (a )),
89+ ("Fourier transformation" , lambda : np .fft .fft (a )),
90+ ("Summation" , lambda : np .sum (a )),
9191 ]
9292
9393 for name , test_func in tests :
94- print_with_timestamp (f"BEGIN TEST: { name } " , file = output_file )
94+ print_with_timestamp (f"BEGIN TEST: { name } " , file = OUTPUT_FILE )
9595 start = time .time ()
9696 for _ in range (iterations ):
9797 test_func ()
9898 end = time .time ()
9999 print_with_timestamp (
100- f"Time for { name .lower ()} : { (end - start ):.4f} seconds" , file = output_file
100+ f"Time for { name .lower ()} : { (end - start ):.4f} seconds" , file = OUTPUT_FILE
101101 )
102- print_with_timestamp ("END TEST / BEGIN NEXT TEST" , file = output_file )
102+ print_with_timestamp ("END TEST / BEGIN NEXT TEST" , file = OUTPUT_FILE )
103103
104104
105105def main ():
106106 """Run the NumPy benchmark suite."""
107107 print_with_timestamp (
108108 f"Producing information for VENV ----> { os .getenv ('CONDA_DEFAULT_ENV' )} " ,
109- file = output_file ,
109+ file = OUTPUT_FILE ,
110110 )
111111
112112 # Capture np.show_config() output and print it line by line with timestamps
@@ -117,17 +117,17 @@ def main():
117117 sys .stdout = old_stdout
118118
119119 for line in new_stdout .getvalue ().split ("\n " ):
120- print_with_timestamp (line , file = output_file )
120+ print_with_timestamp (line , file = OUTPUT_FILE )
121121
122122 if args .skip_tests :
123123 print_with_timestamp (
124- "############### SKIPPING PERFORMANCE CHECKS" , file = output_file
124+ "############### SKIPPING PERFORMANCE CHECKS" , file = OUTPUT_FILE
125125 )
126126 else :
127127 do_tests ()
128128
129- if output_file :
130- output_file .close ()
129+ if OUTPUT_FILE :
130+ OUTPUT_FILE .close ()
131131
132132
133133if __name__ == "__main__" :
0 commit comments