Skip to content

Commit f98a580

Browse files
committed
修正路徑問題
1 parent c04a8f0 commit f98a580

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

benchmarks/run_benchmark.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
import timeit
22
import glob
33
import os
4+
import sys
45
import argparse
56
import math
67
import numpy as np
78

9+
# 添加專案根目錄到 Python 路徑
10+
# benchmarks/run_benchmark.py -> 專案根目錄
11+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
12+
PROJECT_ROOT = os.path.dirname(SCRIPT_DIR)
13+
sys.path.insert(0, PROJECT_ROOT)
14+
815
# 嘗試 import,如果失敗則提示
916
try:
1017
import fast_jpeg_decoder as fjd
11-
except ImportError:
18+
except ImportError as e:
1219
print("❌ Error: Could not import 'fast_jpeg_decoder'. Make sure the C++ module is compiled and in path.")
20+
print(f" ImportError: {e}")
21+
print(f" Project root: {PROJECT_ROOT}")
1322
exit(1)
1423

1524
try:
1625
from python_implementations import numpy_decoder
17-
except ImportError:
26+
except ImportError as e:
1827
print("❌ Error: Could not import 'numpy_decoder' from 'python_implementations'.")
28+
print(f" ImportError: {e}")
29+
print(f" Project root: {PROJECT_ROOT}")
1930
exit(1)
2031

2132
# --- Configuration ---
22-
TEST_DATA_DIR = 'tests/test_data'
33+
TEST_DATA_DIR = os.path.join(PROJECT_ROOT, 'tests/test_data')
2334
OUTPUT_DIR = 'output'
2435
NUMBER_OF_RUNS = 10
2536

0 commit comments

Comments
 (0)