Skip to content

Commit

Permalink
do run perf tests, fix warnings and simplify output (only one backend…
Browse files Browse the repository at this point in the history
…: python-cryptography

git-svn-id: https://xpra.org/svn/Xpra/trunk@23210 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 19, 2019
1 parent 0ea27c6 commit 0344fb0
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/unittests/unit/net/crypto_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

from xpra.net.crypto import DEFAULT_SALT, DEFAULT_ITERATIONS, DEFAULT_BLOCKSIZE, DEFAULT_IV

SHOW_PERF = envbool("XPRA_SHOW_PERF")
SHOW_PERF = envbool("XPRA_SHOW_PERF", True)


def log(message):
def log(_message):
#print(message[:256])
pass

Expand All @@ -28,10 +28,11 @@ def setUp(self):

def do_test_backend(self, message=b"some message1234", encrypt_count=1, decrypt_count=1):
def mustequ(l):
if len(l)==0:
if not l:
return
v = l[0]
for i in range(len(l)):
size = len(l)
for i in range(size):
assert l[i]==v

password = "this is our secret"
Expand Down Expand Up @@ -79,33 +80,31 @@ def test_backends(self):

def do_test_perf(self, size=1024*4, enc_iterations=20, dec_iterations=20):
asize = (size+15)//16
print("test_perf: size: %i Bytes" % (asize*16))
if len(self.backends)<2:
return
times = []
data = b"0123456789ABCDEF"*asize
start = monotonic_time()
self.do_test_backend(data, enc_iterations, dec_iterations)
end = monotonic_time()
i = self.backend.get_info()
elapsed = end-start
speed = (asize*16) * (enc_iterations + dec_iterations) / elapsed
print("%-32s took %5.1fms: %16iKB/s" % (i.get("backend"), elapsed*1000/(enc_iterations + dec_iterations), speed/1024))
iter_time = elapsed*1000/(enc_iterations + dec_iterations)
print("%10iKB: %5.1fms: %16iMB/s" % (asize*16//1024, iter_time, speed//1024//1024))
times.append(end-start)
return times

def test_perf(self):
if not SHOW_PERF:
return
#RANGE = (1, 256, 1024, 1024*1024, 1024*1024*16)
RANGE = (1, 1024, 1024*1024)
print("Encryption Performance:")
RANGE = (1024, 1024*1024)
print("Python Cryptography:")
print(" Encryption:")
for i in RANGE:
self.do_test_perf(i, 10, 0)
print("Decryption Performance:")
print(" Decryption:")
for i in RANGE:
self.do_test_perf(i, 1, 10)
print("Global Performance:")
print(" Overall:")
for i in RANGE:
self.do_test_perf(i, 10, 10)

Expand Down

0 comments on commit 0344fb0

Please sign in to comment.