mirror of https://gitlab.com/bashrc2/epicyon
Single and multiple character change test
parent
e584076aca
commit
bbe414d3a6
13
tests.py
13
tests.py
|
@ -2101,7 +2101,7 @@ def testConstantTimeStringCheck():
|
||||||
end = time.time()
|
end = time.time()
|
||||||
avTime1 = ((end - start) * 1000000 / itterations)
|
avTime1 = ((end - start) * 1000000 / itterations)
|
||||||
|
|
||||||
# change characters and observe timing difference
|
# change a single character and observe timing difference
|
||||||
start = time.time()
|
start = time.time()
|
||||||
for timingTest in range(itterations):
|
for timingTest in range(itterations):
|
||||||
constantTimeStringCheck('nnjfbefefbsnjsdnvbcueftqfeuqfbqefnjeniwufgy',
|
constantTimeStringCheck('nnjfbefefbsnjsdnvbcueftqfeuqfbqefnjeniwufgy',
|
||||||
|
@ -2112,6 +2112,17 @@ def testConstantTimeStringCheck():
|
||||||
# time difference should be less than 10uS
|
# time difference should be less than 10uS
|
||||||
assert timeDiffMicroseconds < 10
|
assert timeDiffMicroseconds < 10
|
||||||
|
|
||||||
|
# change multiple characters and observe timing difference
|
||||||
|
start = time.time()
|
||||||
|
for timingTest in range(itterations):
|
||||||
|
constantTimeStringCheck('nnjfbefefbsnjsdnvbcueftqfeuqfbqefnjeniwufgy',
|
||||||
|
'ano1befffbsn7sd3vbluef6qseuqfpqeznjgni9bfgi')
|
||||||
|
end = time.time()
|
||||||
|
avTime2 = ((end - start) * 1000000 / itterations)
|
||||||
|
timeDiffMicroseconds = abs(avTime2 - avTime1)
|
||||||
|
# time difference should be less than 10uS
|
||||||
|
assert timeDiffMicroseconds < 10
|
||||||
|
|
||||||
|
|
||||||
def runAllTests():
|
def runAllTests():
|
||||||
print('Running tests...')
|
print('Running tests...')
|
||||||
|
|
Loading…
Reference in New Issue