pikapython/port/linux/ci_benchmark_calibration.py

42 lines
1.5 KiB
Python
Raw Normal View History

2022-01-04 15:32:30 +08:00
#!/usr/bin/python3
import json
with open('benchmark_result.json', 'r', encoding='utf8') as json_in:
json_data = dict(json.load(json_in))
benchmarks_data = list(json_data['benchmarks'])
c_base_real_time = benchmarks_data[-1]['cpu_time']
c_base_cali_time = 0.005
cali_ratio = c_base_cali_time/c_base_real_time
print('c_base_real_time:', c_base_real_time)
print('c_base_cali_time:', c_base_cali_time)
print('cali_ratio:', cali_ratio)
for i in range(len(benchmarks_data)):
benchmarks_data[i]['cpu_time'] *= cali_ratio
benchmarks_data[i]['real_time'] *= cali_ratio
2022-01-05 21:22:54 +08:00
benchmarks_data[i]['family_index'] += 1
2022-01-04 15:32:30 +08:00
2022-01-05 21:22:54 +08:00
# new a banchmark
benchmarks_data.insert(0, benchmarks_data[0].copy())
performance_point_name = 'Performance Points'
2022-01-05 21:55:42 +08:00
performance_point_res = benchmarks_data[-1]['cpu_time'] / \
benchmarks_data[-2]['cpu_time'] * 100 * 100000
2022-01-05 21:22:54 +08:00
benchmarks_data[0]['name'] = performance_point_name
benchmarks_data[0]['run_name'] = performance_point_name
benchmarks_data[0]['family_index'] = 0
benchmarks_data[0]['repetitions'] = 1
benchmarks_data[0]['iterations'] = 1
2022-01-05 21:55:42 +08:00
benchmarks_data[0]['real_time'] = performance_point_res
benchmarks_data[0]['cpu_time'] = performance_point_res
2022-01-05 21:22:54 +08:00
benchmarks_data[0]['time_unit'] = 'Point'
2022-01-04 15:32:30 +08:00
2022-01-05 21:55:42 +08:00
print('---------------------------------------------')
print('Perfomance point:', int(performance_point_res))
2022-01-05 21:22:54 +08:00
# update json_data
json_data['benchmarks'] = benchmarks_data
# save json
2022-01-04 15:32:30 +08:00
with open('benchmark_result.json', 'w') as json_out:
2022-01-05 21:22:54 +08:00
json.dump(json_data, json_out)