Skip to content

Commit 37965f3

Browse files
committed
final
Signed-off-by: Yang Wang <[email protected]>
1 parent 44b792b commit 37965f3

File tree

3 files changed

+60
-4
lines changed

3 files changed

+60
-4
lines changed

.ci/scripts/benchmark_tooling/README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Install dependencies:
1313
pip install -r requirements.txt
1414
```
1515

16-
Run with default output (CLI):
16+
Run with csv output (CLI):
1717
```bash
18-
python3 .ci/scripts/benchmark_tooling/get_benchmark_analysis_data.py --startTime "2025-06-11T00:00:00" --endTime "2025-06-17T18:00:00"
18+
python3 .ci/scripts/benchmark_tooling/get_benchmark_analysis_data.py --startTime "2025-06-11T00:00:00" --endTime "2025-06-17T18:00:00" --outputType "csv"
1919
```
2020

2121
Additional options:
@@ -24,6 +24,23 @@ Additional options:
2424
- `--outputType excel --outputDir "{YOUR_LOCAL_DIRECTORY}"`: Generate Excel file with multiple sheets (`res_private.xlsx` and `res_public.xlsx`)
2525
- `--outputType csv --outputDir "{YOUR_LOCAL_DIRECTORY}"`: Generate CSV files in folders (`private` and `public`)
2626

27+
you can then call methods in common.py to convert the file date back to df version
28+
```python3
29+
import logging
30+
logging.basicConfig(level=logging.INFO)
31+
from common.py import
32+
33+
# assume the folder private for csv is in cunrrent directory
34+
folder_path = './private'
35+
res = read_all_csv_with_metadata(folder_path)
36+
logging.info(res)
37+
38+
# assume the excel file for private device is in cunrrent directory
39+
folder_path = "./private.xlsx"
40+
res = read_excel_with_json_header(folder_path)
41+
logging.info(res)
42+
```
43+
2744
### Python API Usage
2845

2946
To use the benchmark fetcher in your own scripts:
@@ -33,7 +50,7 @@ import ExecutorchBenchmarkFetcher from benchmark_tooling.get_benchmark_analysis_
3350
fetcher = ExecutorchBenchmarkFetcher()
3451
# Must call run first
3552
fetcher.run()
36-
private, public = fetcher.to_df()
53+
res = fetcher.
3754
```
3855

3956
## analyze_benchmark_stability.py
@@ -50,7 +67,6 @@ python .ci/scripts/benchmark_tooling/analyze_benchmark_stability.py \
5067
Benchmark\ Dataset\ with\ Private\ AWS\ Devices.xlsx \
5168
--reference_file Benchmark\ Dataset\ with\ Public\ AWS\ Devices.xlsx
5269
```
53-
5470
## Run unittest
5571
```
5672
cd execuTorch/
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import json
2+
import os
3+
4+
import pandas as pd
5+
6+
7+
def read_excel_with_json_header(path: str):
8+
# Read all sheets into a dict of DataFrames, without altering
9+
all_sheets = pd.read_excel(path, sheet_name=None, header=None, engine="openpyxl")
10+
11+
results = []
12+
for sheet, df in all_sheets.items():
13+
# Extract JSON string from A1 (row 0, col 0)
14+
json_str = df.iat[0, 0]
15+
meta = json.loads(json_str) if isinstance(json_str, str) else {}
16+
17+
# The actual data starts from the next row; treat row 1 as header
18+
df_data = pd.read_excel(path, sheet_name=sheet, skiprows=1, engine="openpyxl")
19+
results.append({"groupInfo": meta, "df": df_data})
20+
print(f"successfully fetched {len(results)} sheets from {path}")
21+
return results
22+
23+
24+
def read_all_csv_with_metadata(folder_path: str):
25+
results = [] # {filename: {"meta": dict, "df": DataFrame}}
26+
for fname in os.listdir(folder_path):
27+
if not fname.lower().endswith(".csv"):
28+
continue
29+
path = os.path.join(folder_path, fname)
30+
with open(path, "r", encoding="utf-8") as f:
31+
first_line = f.readline().strip()
32+
try:
33+
meta = json.loads(first_line)
34+
except json.JSONDecodeError:
35+
meta = {}
36+
df = pd.read_csv(path, skiprows=1)
37+
results.append({"groupInfo": meta, "df": df})
38+
print(f"successfully fetched {len(results)} sheets from {folder_path}")
39+
return results

.ci/scripts/benchmark_tooling/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ pandas>=2.3.0
44
openpyxl
55
tabulate
66
matplotlib
7+
openpyxl

0 commit comments

Comments
 (0)