I'm trying to benchmark the bundling process of our js bundles using pytest-benchmark. For accurate processing the target directory needs to empty. I've tried cleaning this on each run using the pedantic setup argument, but this only runs on initialization of the benchmark, and not in between runs. This is the code of my last try:
import shutil
import os
import pytest
def clean_bundles():
print("Cleaning bundles")
shutil.rmtree(os.path.abspath('precompiled'), True)
def bundle(gulpfile):
os.system("gulp --gulpfile %s createBundles" % gulpfile)
def test_bundle(benchmark):
benchmark.pedantic(lambda: bundle("gulpfile.js"), setup=clean_bundles(), rounds=5, iterations=1)
Is there anyway to run a clean between each iteration without making it part of the benchmark results?