diff --git a/benchmarks/124_minus_x.py b/benchmarks/124_minus_x.py index fb192944e..aa74101d0 100644 --- a/benchmarks/124_minus_x.py +++ b/benchmarks/124_minus_x.py @@ -1,4 +1,4 @@ -# Target: 124 - x +# Unit Target: 124 - x import random diff --git a/benchmarks/124_minus_x_tensor.py b/benchmarks/124_minus_x_tensor.py index eab8fcafe..8b2db4834 100644 --- a/benchmarks/124_minus_x_tensor.py +++ b/benchmarks/124_minus_x_tensor.py @@ -1,4 +1,4 @@ -# Target: 124 - x (Tensor) +# Unit Target: 124 - x (Tensor) import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/linear_regression.py b/benchmarks/linear_regression.py index e71f63cb7..0612456d0 100644 --- a/benchmarks/linear_regression.py +++ b/benchmarks/linear_regression.py @@ -1,4 +1,4 @@ -# Target: Linear Regression +# Full Target: Linear Regression # Disable line length warnings as we have a looooong metric... # flake8: noqa: E501 diff --git a/benchmarks/logistic_regression.py b/benchmarks/logistic_regression.py index 1d7de17c3..79eeb3a0a 100644 --- a/benchmarks/logistic_regression.py +++ b/benchmarks/logistic_regression.py @@ -1,4 +1,4 @@ -# Target: Logistic Regression +# Full Target: Logistic Regression import numpy as np import torch diff --git a/benchmarks/single_table_lookup.py b/benchmarks/single_table_lookup.py index 0f0541398..2b650319a 100644 --- a/benchmarks/single_table_lookup.py +++ b/benchmarks/single_table_lookup.py @@ -1,4 +1,4 @@ -# Target: Single Table Lookup +# Unit Target: Single Table Lookup import random diff --git a/benchmarks/x_minus_1_2_3.py b/benchmarks/x_minus_1_2_3.py index 0e696dc8a..9b1f59071 100644 --- a/benchmarks/x_minus_1_2_3.py +++ b/benchmarks/x_minus_1_2_3.py @@ -1,4 +1,4 @@ -# Target: x - [1, 2, 3] +# Unit Target: x - [1, 2, 3] import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_minus_1_2_3_broadcasted.py b/benchmarks/x_minus_1_2_3_broadcasted.py index f1473f062..64f583384 100644 --- a/benchmarks/x_minus_1_2_3_broadcasted.py +++ b/benchmarks/x_minus_1_2_3_broadcasted.py @@ -1,4 +1,4 @@ -# Target: x - [1, 2, 3] (Broadcasted) +# Unit Target: x - [1, 2, 3] (Broadcasted) import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_minus_24.py b/benchmarks/x_minus_24.py index 3bca798d1..2b03e8d8d 100644 --- a/benchmarks/x_minus_24.py +++ b/benchmarks/x_minus_24.py @@ -1,4 +1,4 @@ -# Target: x - 24 +# Unit Target: x - 24 import random diff --git a/benchmarks/x_minus_24_tensor.py b/benchmarks/x_minus_24_tensor.py index 3961c94bd..06bd641b7 100644 --- a/benchmarks/x_minus_24_tensor.py +++ b/benchmarks/x_minus_24_tensor.py @@ -1,4 +1,4 @@ -# Target: x - 24 (Tensor) +# Unit Target: x - 24 (Tensor) import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_minus_y.py b/benchmarks/x_minus_y.py index b7d5db488..3f6413bda 100644 --- a/benchmarks/x_minus_y.py +++ b/benchmarks/x_minus_y.py @@ -1,4 +1,4 @@ -# Target: x - y +# Unit Target: x - y import itertools import random diff --git a/benchmarks/x_minus_y_broadcasted_tensors.py b/benchmarks/x_minus_y_broadcasted_tensors.py index 808575c49..c9b7b9077 100644 --- a/benchmarks/x_minus_y_broadcasted_tensors.py +++ b/benchmarks/x_minus_y_broadcasted_tensors.py @@ -1,4 +1,4 @@ -# Target: x - y (Broadcasted Tensors) +# Unit Target: x - y (Broadcasted Tensors) import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_minus_y_tensor_and_scalar.py b/benchmarks/x_minus_y_tensor_and_scalar.py index 8e69743b9..56f118d2d 100644 --- a/benchmarks/x_minus_y_tensor_and_scalar.py +++ b/benchmarks/x_minus_y_tensor_and_scalar.py @@ -1,4 +1,4 @@ -# Target: x - y (Tensor & Scalar) +# Unit Target: x - y (Tensor & Scalar) import random diff --git a/benchmarks/x_minus_y_tensors.py b/benchmarks/x_minus_y_tensors.py index 3858563f3..f6f1ad44c 100644 --- a/benchmarks/x_minus_y_tensors.py +++ b/benchmarks/x_minus_y_tensors.py @@ -1,4 +1,4 @@ -# Target: x - y (Tensors) +# Unit Target: x - y (Tensors) import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_plus_1_2_3.py b/benchmarks/x_plus_1_2_3.py index 7503d78cd..2292e3460 100644 --- a/benchmarks/x_plus_1_2_3.py +++ b/benchmarks/x_plus_1_2_3.py @@ -1,4 +1,4 @@ -# Target: x + [1, 2, 3] +# Unit Target: x + [1, 2, 3] import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_plus_1_2_3_broadcasted.py b/benchmarks/x_plus_1_2_3_broadcasted.py index 36132d3d6..eb5e156ac 100644 --- a/benchmarks/x_plus_1_2_3_broadcasted.py +++ b/benchmarks/x_plus_1_2_3_broadcasted.py @@ -1,4 +1,4 @@ -# Target: x + [1, 2, 3] (Broadcasted) +# Unit Target: x + [1, 2, 3] (Broadcasted) import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_plus_42.py b/benchmarks/x_plus_42.py index d74ff023e..41b27b36a 100644 --- a/benchmarks/x_plus_42.py +++ b/benchmarks/x_plus_42.py @@ -1,4 +1,4 @@ -# Target: x + 42 +# Unit Target: x + 42 import random diff --git a/benchmarks/x_plus_42_tensor.py b/benchmarks/x_plus_42_tensor.py index a709b788e..9395926a1 100644 --- a/benchmarks/x_plus_42_tensor.py +++ b/benchmarks/x_plus_42_tensor.py @@ -1,4 +1,4 @@ -# Target: x + 42 (Tensor) +# Unit Target: x + 42 (Tensor) import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_plus_y.py b/benchmarks/x_plus_y.py index 39aae0377..bdf944d92 100644 --- a/benchmarks/x_plus_y.py +++ b/benchmarks/x_plus_y.py @@ -1,4 +1,4 @@ -# Target: x + y +# Unit Target: x + y import random diff --git a/benchmarks/x_plus_y_broadcasted_tensors.py b/benchmarks/x_plus_y_broadcasted_tensors.py index b2408d13f..e3960e895 100644 --- a/benchmarks/x_plus_y_broadcasted_tensors.py +++ b/benchmarks/x_plus_y_broadcasted_tensors.py @@ -1,4 +1,4 @@ -# Target: x + y (Broadcasted Tensors) +# Unit Target: x + y (Broadcasted Tensors) import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_plus_y_tensor_and_scalar.py b/benchmarks/x_plus_y_tensor_and_scalar.py index 94224b449..8de52337c 100644 --- a/benchmarks/x_plus_y_tensor_and_scalar.py +++ b/benchmarks/x_plus_y_tensor_and_scalar.py @@ -1,4 +1,4 @@ -# Target: x + y (Tensor & Scalar) +# Unit Target: x + y (Tensor & Scalar) import random diff --git a/benchmarks/x_plus_y_tensors.py b/benchmarks/x_plus_y_tensors.py index 836d89c97..79693d82f 100644 --- a/benchmarks/x_plus_y_tensors.py +++ b/benchmarks/x_plus_y_tensors.py @@ -1,4 +1,4 @@ -# Target: x + y (Tensors) +# Unit Target: x + y (Tensors) import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_times_1_2_3.py b/benchmarks/x_times_1_2_3.py index 040297c88..c6bd26c7d 100644 --- a/benchmarks/x_times_1_2_3.py +++ b/benchmarks/x_times_1_2_3.py @@ -1,4 +1,4 @@ -# Target: x * [1, 2, 3] +# Unit Target: x * [1, 2, 3] import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_times_1_2_3_broadcasted.py b/benchmarks/x_times_1_2_3_broadcasted.py index 77d56aa57..41e2b25f7 100644 --- a/benchmarks/x_times_1_2_3_broadcasted.py +++ b/benchmarks/x_times_1_2_3_broadcasted.py @@ -1,4 +1,4 @@ -# Target: x * [1, 2, 3] (Broadcasted) +# Unit Target: x * [1, 2, 3] (Broadcasted) import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_times_7.py b/benchmarks/x_times_7.py index 156aafa1d..f82454750 100644 --- a/benchmarks/x_times_7.py +++ b/benchmarks/x_times_7.py @@ -1,4 +1,4 @@ -# Target: x * 7 +# Unit Target: x * 7 import random diff --git a/benchmarks/x_times_7_tensor.py b/benchmarks/x_times_7_tensor.py index c92d02031..f65cb6e92 100644 --- a/benchmarks/x_times_7_tensor.py +++ b/benchmarks/x_times_7_tensor.py @@ -1,4 +1,4 @@ -# Target: x * 7 (Tensor) +# Unit Target: x * 7 (Tensor) import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_times_y.py b/benchmarks/x_times_y.py index 50dc97d13..fd8092ffc 100644 --- a/benchmarks/x_times_y.py +++ b/benchmarks/x_times_y.py @@ -1,4 +1,4 @@ -# Target: x * y +# Unit Target: x * y import itertools import random diff --git a/benchmarks/x_times_y_broadcasted_tensors.py b/benchmarks/x_times_y_broadcasted_tensors.py index c830ea77c..18d50a74e 100644 --- a/benchmarks/x_times_y_broadcasted_tensors.py +++ b/benchmarks/x_times_y_broadcasted_tensors.py @@ -1,4 +1,4 @@ -# Target: x * y (Broadcasted Tensors) +# Unit Target: x * y (Broadcasted Tensors) import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_times_y_tensor_and_scalar.py b/benchmarks/x_times_y_tensor_and_scalar.py index 7b7bad7e4..bd2cccaac 100644 --- a/benchmarks/x_times_y_tensor_and_scalar.py +++ b/benchmarks/x_times_y_tensor_and_scalar.py @@ -1,4 +1,4 @@ -# Target: x * y (Tensor & Scalar) +# Unit Target: x * y (Tensor & Scalar) import random diff --git a/benchmarks/x_times_y_tensors.py b/benchmarks/x_times_y_tensors.py index 7d561eb4a..adefc6b4b 100644 --- a/benchmarks/x_times_y_tensors.py +++ b/benchmarks/x_times_y_tensors.py @@ -1,4 +1,4 @@ -# Target: x * y (Tensors) +# Unit Target: x * y (Tensors) import numpy as np from common import BENCHMARK_CONFIGURATION diff --git a/benchmarks/x_to_the_power_of_2.py b/benchmarks/x_to_the_power_of_2.py index 4391f6ad0..61a5f4577 100644 --- a/benchmarks/x_to_the_power_of_2.py +++ b/benchmarks/x_to_the_power_of_2.py @@ -1,4 +1,4 @@ -# Target: x**2 +# Unit Target: x**2 import random diff --git a/script/progress_tracker_utils/measure.py b/script/progress_tracker_utils/measure.py index 231e0f087..069d688fb 100644 --- a/script/progress_tracker_utils/measure.py +++ b/script/progress_tracker_utils/measure.py @@ -284,15 +284,8 @@ def perform_measurements(path, script, target_id, metrics, samples, result): del result["targets"][target_id]["measurements"] -def main(): +def main(args): """Measurement script for the progress tracker""" - parser = argparse.ArgumentParser(description="Measurement script for the progress tracker") - - parser.add_argument("base", type=str, help="directory which contains the benchmarks") - parser.add_argument("--samples", type=int, default=30, help="number of samples to take") - parser.add_argument("--keep", action="store_true", help="flag to keep measurement scripts") - - args = parser.parse_args() base = pathlib.Path(args.base) samples = args.samples @@ -328,7 +321,15 @@ def main(): break # Check whether the script is a target or not - if not first_line.startswith("# Target:"): + if first_line.startswith("# Unit Target:"): + # Extract target name + target_name = first_line.replace("# Unit Target:", "").strip() + is_unit = True + elif first_line.startswith("# Full Target:"): + # Extract target name + target_name = first_line.replace("# Full Target:", "").strip() + is_unit = False + else: print() print(path) print("-" * len(str(path))) @@ -342,8 +343,7 @@ def main(): print() continue - # Extract target name and id - target_name = first_line.replace("# Target:", "").strip() + # Extract target id target_id = name_to_id(target_name) # Check whether the target is already registered @@ -371,6 +371,7 @@ def main(): "measurements": {}, "alerts": alerts, "code": "\n".join(lines), + "isUnit": is_unit, } # Perform and save measurements @@ -388,4 +389,10 @@ def main(): if __name__ == "__main__": - main() + parser = argparse.ArgumentParser(description="Measurement script for the progress tracker") + + parser.add_argument("base", type=str, help="directory which contains the benchmarks") + parser.add_argument("--samples", type=int, default=30, help="number of samples to take") + parser.add_argument("--keep", action="store_true", help="flag to keep measurement scripts") + + main(parser.parse_args())