mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
Added/Updated tests\bugs\gh_7092_test.py: changed ratio and limits - see notes.
This commit is contained in:
parent
c7f75bf41d
commit
f5fc896942
@ -13,15 +13,20 @@ DESCRIPTION:
|
||||
We do these measures <N_MEASURES> times for each SP, and each result is added to the list
|
||||
which, in turn, is the source for median evaluation.
|
||||
Finally, we get ratio between minimal and maximal medians (see 'median_ratio')
|
||||
On Windows 8.1 usually this ratio is about 7 (before fix it was more than 100).
|
||||
This ratio is about:
|
||||
* Windows: 0.6 ... 0.7
|
||||
* Linux: 0.5 ... 0.6
|
||||
Before fix it was more than 10.
|
||||
|
||||
Test is considered as passed if median_ratio less than threshold <MAX_RATIO>.
|
||||
NOTES:
|
||||
Number of iterations for loops differ: we have to perform 'sp_empty_loop' at least 1E6 times
|
||||
in order to get valuable difference between CPU user time counters and use it as denomitator.
|
||||
Procedure 'sp_ctime_loop' must be called for 10x times LESS than 'sp_empty_loop'.
|
||||
|
||||
Confirmed problem on:
|
||||
4.0.1.2699 (01-jan-2022): median ratio was 109 ... 110 (3.40 vs 0.03)
|
||||
5.0.0.362 (01-jan-2022): median ratio was 111 ... 113 (3.51 vs 0.03)
|
||||
5.0.0.362, 4.0.1.2699 (bith snapshots have date 01-jan-2022)
|
||||
Checked on 6.0.0.195, 5.0.0.1305, 4.0.5.3049.
|
||||
Scope of median ratio values: 4.33 ... 7.00
|
||||
"""
|
||||
|
||||
import psutil
|
||||
@ -43,12 +48,13 @@ def median(lst):
|
||||
N_MEASURES = 15
|
||||
|
||||
# How many iterations must be done:
|
||||
N_COUNT_PER_MEASURE = 100000
|
||||
N_COUNT_TIME_LOOP = 100000
|
||||
N_COUNT_EMPTY_LOOP = 1000000
|
||||
|
||||
# Maximal value for ratio between maximal and minimal medians
|
||||
#
|
||||
MAX_RATIO = 15
|
||||
##############
|
||||
MAX_RATIO = 1.5
|
||||
###############
|
||||
|
||||
init_script = \
|
||||
f'''
|
||||
@ -60,12 +66,12 @@ f'''
|
||||
begin
|
||||
while (n < a_limit) do
|
||||
begin
|
||||
n = n + 1;
|
||||
d = current_time;
|
||||
n = n + 1;
|
||||
end
|
||||
end
|
||||
^
|
||||
create procedure sp_dummy_loop(a_limit int)
|
||||
create procedure sp_empty_loop(a_limit int)
|
||||
as
|
||||
declare n int = 1;
|
||||
begin
|
||||
@ -79,7 +85,7 @@ f'''
|
||||
^
|
||||
'''
|
||||
|
||||
db = db_factory(init = init_script)
|
||||
db = db_factory(init = init_script, charset = 'win1251')
|
||||
act = python_act('db')
|
||||
|
||||
expected_stdout = """
|
||||
@ -96,24 +102,25 @@ def test_1(act: Action, capsys):
|
||||
|
||||
sp_time = {}
|
||||
for i in range(0, N_MEASURES):
|
||||
for sp_name in ('sp_ctime_loop', 'sp_dummy_loop'):
|
||||
for sp_name in ('sp_ctime_loop', 'sp_empty_loop'):
|
||||
n_count = N_COUNT_TIME_LOOP if sp_name == 'sp_ctime_loop' else N_COUNT_EMPTY_LOOP
|
||||
fb_info_init = psutil.Process(fb_pid).cpu_times()
|
||||
cur.callproc( sp_name, (N_COUNT_PER_MEASURE,) )
|
||||
cur.callproc( sp_name, (n_count,) )
|
||||
fb_info_curr = psutil.Process(fb_pid).cpu_times()
|
||||
sp_time[ sp_name, i ] = max(fb_info_curr.user - fb_info_init.user, 0.000001)
|
||||
|
||||
|
||||
sp_ctime_median = median([v for k,v in sp_time.items() if k[0] == 'sp_ctime_loop'])
|
||||
sp_dummy_median = median([v for k,v in sp_time.items() if k[0] == 'sp_dummy_loop'])
|
||||
sp_dummy_median = median([v for k,v in sp_time.items() if k[0] == 'sp_empty_loop'])
|
||||
#----------------------------------
|
||||
median_ratio = sp_ctime_median / sp_dummy_median
|
||||
|
||||
print( 'Medians ratio: ' + ('acceptable' if median_ratio <= MAX_RATIO else '/* perf_issue_tag */ POOR: %s, more than threshold: %s' % ( '{:9g}'.format(median_ratio), '{:9g}'.format(MAX_RATIO) ) ) )
|
||||
if median_ratio > MAX_RATIO:
|
||||
print('CPU times for each of {N_MEASURES} measures:')
|
||||
print(f'CPU times for each of {N_MEASURES} measures:')
|
||||
for k,v in sp_time.items():
|
||||
print(k,':::',v)
|
||||
print(f'Median cpu time for {N_MEASURES} measures using loops for {N_COUNT_PER_MEASURE} iterations in each SP call:')
|
||||
print(f'Median cpu time for {N_MEASURES} measures:')
|
||||
print('sp_ctime_median:',sp_ctime_median)
|
||||
print('sp_dummy_median:',sp_dummy_median)
|
||||
print('median_ratio:',median_ratio)
|
||||
|
Loading…
Reference in New Issue
Block a user