MCPcopy Create free account
hub / github.com/comaps/comaps / compare_two_versions

Function compare_two_versions

tools/python/routing/run_heap_comparison_benchmark.py:161–210  ·  view source on GitHub ↗
(*, config_ini, old_version_data, new_version_data)

Source from the content-addressed store, hash-verified

159# Calculate some stat comparison about maximum memory usage in two versions, creates some plots to look at this stat
160# by eyes.
161def compare_two_versions(*, config_ini, old_version_data, new_version_data):
162 old_version = old_version_data['version']
163 new_version = new_version_data['version']
164
165 old_version_name = old_version['name']
166 new_version_name = new_version['name']
167
168 results_save_dir = config_ini.read_value_by_path(path=['PATHS', 'ResultsSaveDir'])
169 results_path_prefix = os.path.join(results_save_dir, f'{old_version_name}__{new_version_name}')
170
171 utils.log_with_stars(f'Compare {old_version_name} VS {new_version_name}')
172
173 diff = []
174
175 old_version_results = old_version_data['results']
176 new_version_results = new_version_data['results']
177 for route_id, old_max_mb in old_version_results.items():
178 if route_id not in new_version_results:
179 LOG.info(f'Cannot find: {route_id} route in {new_version_name} results.')
180 continue
181
182 new_max_mb = new_version_results[route_id]
183
184 diff_mb = new_max_mb - old_max_mb
185 diff_percent = round((new_max_mb - old_max_mb) / old_max_mb * 100.0, 2)
186 diff.append({'mb': diff_mb, 'percent': diff_percent})
187
188 diff.sort(key=lambda item: item['mb'])
189
190 min_mb = get_by_func_and_key_in_diff(diff=diff, key='mb', func=min)
191 median_mb = get_median_by_key_in_diff(diff=diff, key='mb')
192 max_mb = get_by_func_and_key_in_diff(diff=diff, key='mb', func=max)
193
194 min_percent = get_by_func_and_key_in_diff(diff=diff, key='percent', func=min)
195 median_percent = get_median_by_key_in_diff(diff=diff, key='percent')
196 max_percent = get_by_func_and_key_in_diff(diff=diff, key='percent', func=max)
197
198 LOG.info(f'Next semantic is used: {old_version_name} - {new_version_name}')
199 LOG.info(f'min({min_mb}Mb), median({median_mb}Mb) max({max_mb}Mb)')
200 LOG.info(f'min({min_percent}%), median({median_percent}%) max({max_percent}%)')
201
202 diff_mb_script = f'{results_path_prefix}__diff_mb.py'
203 diff_mb = list(map(lambda item: item['mb'], diff))
204 graph_scripts.create_distribution_script(values=diff_mb, title='Difference MB', save_path=diff_mb_script)
205
206 plots_script = f'{results_path_prefix}__mb_percents.py'
207 plots = create_diff_mb_percents_plots(diff)
208 graph_scripts.create_plots(plots=plots, xlabel='Route number', ylabel='conventional units', save_path=plots_script)
209
210 LOG.info(os.linesep, os.linesep)
211
212def run_results_comparison(*, config_ini, old_versions, new_versions, data_from_heap_comparison):
213 for old_version in old_versions:

Callers 1

run_results_comparisonFunction · 0.85

Calls 8

mapFunction · 0.85
read_value_by_pathMethod · 0.80
joinMethod · 0.45
appendMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected