You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[benchmark] Add script to automate creation of new single-source benchmarks
Adds a `create_benchmark` script that automates the following three tasks:
1. Add a new Swift file (YourTestNameHere.swift), built according to the template below, to the {{single-source}}directory.
2. Add the filename of the new Swift file to CMakeLists.txt
3. Edit main.swift. Import and register your new Swift module.
The process of adding new benchmarks is now automated and a lot less error-prone.
# the test dependencies are placed before all benchmarks, so we have to insert the benchmark in the right alphabetical order after we have seen all test dependencies.
77
+
read_test_dependencies=False
78
+
previous_benchmark_name=None
79
+
file_new_contents= []
80
+
forlineinfile_contents:
81
+
# check if this line is a definition of a benchmark and get its name
82
+
match=re.search(r"import ([a-zA-Z]+)", line)
83
+
ifmatchandmatch.group(1):
84
+
benchmark_name=match.group(1)
85
+
# find where to insert the new benchmark in the right alphabetical order
86
+
if (name<benchmark_nameandprevious_benchmark_name==None) or (name<benchmark_nameandname>previous_benchmark_name):
"""Iterates through the given lines and executes the regex on each line to find where the new benchmark should be inserted with the given `new_line`."""
118
+
# the name of the previous seen benchmark in order to insert the new one at the correct position
119
+
previous_benchmark_name=None
120
+
# the new contents of the file
121
+
updated_lines= []
122
+
forlineinlines:
123
+
# apply regex and get name of benchmark on this line
124
+
match=re.search(regex, line)
125
+
ifmatchandmatch.group(1):
126
+
benchmark_name=match.group(1)
127
+
# check if we're at the line where we have to insert the new benchmark in the correct alphabetical order
128
+
if (name<benchmark_nameandprevious_benchmark_name==None) or (name<benchmark_nameandname>previous_benchmark_name):
0 commit comments