add timer to test script
This commit is contained in:
parent
c97f3dfdac
commit
4470c97411
@ -2,6 +2,8 @@ import argparse
|
||||
import re
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
from functools import wraps
|
||||
from pretty_print import Print_C
|
||||
|
||||
# "([1-4]\d|51).*\.sy"
|
||||
@ -19,7 +21,15 @@ def case_collector(re_selector, dir):
|
||||
testcases.append(os.path.splitext(filename)[0])
|
||||
return sorted(testcases)
|
||||
|
||||
|
||||
def func_timer(function):
|
||||
@wraps(function)
|
||||
def function_timer(*args, **kwargs):
|
||||
t0 = time.time()
|
||||
result = function(*args, **kwargs)
|
||||
t1 = time.time()
|
||||
print('[Time elapsed {time:.3f}s]'.format(time=t1 - t0))
|
||||
return result
|
||||
return function_timer
|
||||
|
||||
class Compiler:
|
||||
def __init__(self, scheme, target_dir, testcases):
|
||||
@ -145,7 +155,7 @@ class Compiler:
|
||||
if self.count_error >= error_tolerance:
|
||||
Print_C.print_error(f"Test script stopped due to {self.count_error} errors")
|
||||
return
|
||||
|
||||
@func_timer
|
||||
def run_case(self, testcase, kase=0):
|
||||
bin = self.bin_template.format(testcase=testcase)
|
||||
if not os.path.exists(bin):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user