File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import timeit
22import glob
33import os
4+ import sys
45import argparse
56import math
67import 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,如果失敗則提示
916try :
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
1524try :
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' )
2334OUTPUT_DIR = 'output'
2435NUMBER_OF_RUNS = 10
2536
You can’t perform that action at this time.
0 commit comments