Merge pull request #2571 from ralexstokes/add-timing-info-to-test-gen

add timing information to spec test generation
This commit is contained in:
Danny Ryan 2021-08-26 17:14:52 -06:00 committed by GitHub
commit c45e77b0b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import os import os
import time
import shutil import shutil
import argparse import argparse
from pathlib import Path from pathlib import Path
@ -22,6 +23,9 @@ from .gen_typing import TestProvider
context.is_pytest = False context.is_pytest = False
TIME_THRESHOLD_TO_PRINT = 1.0 # seconds
def validate_output_dir(path_str): def validate_output_dir(path_str):
path = Path(path_str) path = Path(path_str)
@ -98,6 +102,7 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):
generated_test_count = 0 generated_test_count = 0
skipped_test_count = 0 skipped_test_count = 0
provider_start = time.time()
for tprov in test_providers: for tprov in test_providers:
# runs anything that we don't want to repeat for every test case. # runs anything that we don't want to repeat for every test case.
tprov.prepare() tprov.prepare()
@ -122,6 +127,7 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):
shutil.rmtree(case_dir) shutil.rmtree(case_dir)
print(f'Generating test: {case_dir}') print(f'Generating test: {case_dir}')
test_start = time.time()
written_part = False written_part = False
@ -179,9 +185,18 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):
generated_test_count += 1 generated_test_count += 1
# Only remove `INCOMPLETE` tag file # Only remove `INCOMPLETE` tag file
os.remove(incomplete_tag_file) os.remove(incomplete_tag_file)
test_end = time.time()
span = round(test_end - test_start, 2)
if span > TIME_THRESHOLD_TO_PRINT:
print(f' - generated in {span} seconds')
provider_end = time.time()
span = round(provider_end - provider_start, 2)
summary_message = f"completed generation of {generator_name} with {generated_test_count} tests" summary_message = f"completed generation of {generator_name} with {generated_test_count} tests"
summary_message += f" ({skipped_test_count} skipped tests)" summary_message += f" ({skipped_test_count} skipped tests)"
if span > TIME_THRESHOLD_TO_PRINT:
summary_message += f" in {span} seconds"
print(summary_message) print(summary_message)