Created
December 21, 2023 09:45
-
-
Save fengyuentau/3fb35174e1da0cf61ec9bb009153b020 to your computer and use it in GitHub Desktop.
Make markdown table from opencv perf test results. It is used in https://github.com/opencv/opencv/pull/24694 and https://github.com/opencv/opencv/pull/23897.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
| Configuration | Gemm | InnerProduct | | |
| - | - | - | | |
| A=, B=, C=, transA=, transB=| - | - | | |
''' | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--log", "-l", default="m1.log", required=True) | |
parser.add_argument("--no_header", action="store_true") | |
args = parser.parse_args() | |
configs = [] | |
means = [] | |
with open(args.log, "r") as f: | |
lines = f.readlines() | |
for i, line in enumerate(lines): | |
line = line.strip() | |
if line.find("GetParam") != -1 and line.endswith("OCV/CPU)"): | |
start = line.find("A=[") | |
end = line.find(", OCV/CPU)") | |
configs.append(line[start:end]) | |
next_line = lines[i+1] | |
if next_line.find("samples") != -1: | |
start = next_line.find("mean=") | |
end = next_line.find("median=") | |
num = next_line[start+5:end].strip() | |
means.append(float(num)) | |
print(len(configs), len(means)) | |
half = int(len(means) / 2) | |
platform = args.log[:-4] | |
if args.no_header: | |
print(" Gemm-{:s} | InnerProduct-{:s} |".format(platform, platform)) | |
print(" - | - |") | |
for i in range(half): | |
if means[i] <= means[i+half]: | |
print(" **{:.2f}** | {:.2f} |".format(means[i], means[i+half])) | |
else: | |
print(" {:.2f} | **{:.2f}** |".format(means[i], means[i+half])) | |
else: | |
print("| Configuration | Gemm-{:s} | InnerProduct-{:s} |".format(platform, platform)) | |
print("| - | - | - |") | |
for i in range(half): | |
if (means[i] <= means[i+half]): | |
print("| {:s} | **{:.2f}** | {:.2f} | ".format(configs[i], means[i], means[i+half])) | |
else: | |
print("| {:s} | {:.2f} | **{:.2f}** | ".format(configs[i], means[i], means[i+half])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment