Skip to content

Instantly share code, notes, and snippets.

@kwatch
Last active March 4, 2016 08:27
Show Gist options
  • Save kwatch/167e8f7835350142145d to your computer and use it in GitHub Desktop.
Save kwatch/167e8f7835350142145d to your computer and use it in GitHub Desktop.
benchmark: scrumble_uinit32 vs encrypt
# -*- coding: utf-8 -*-
import sys
from benchmarker import Benchmarker
import main
from rchk.utils.simple_crypto import encrypt, decrypt
from rchk.utils import scrumble_uint32
with Benchmarker(loop=1000*1000, cycle=10, extra=1) as bench:
@bench("encrypt()")
def _(bm):
for _ in bm:
x = encrypt('1234567890')
#assert decrypt(x) == b'1234567890'
return x
@bench("scrumble_uint32()")
def _(bm):
for _ in bm:
x = scrumble_uint32(1234567890)
#assert scrumble_uint32(x) == 1234567890
return x
r"""
## benchmarker: release 4.0.1 (for python)
## python version: 3.3.6
## python compiler: GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)
## python platform: Darwin-15.3.0-x86_64-i386-64bit
## python executable: /Users/kwatch/spotlight/rchk-server/venv/bin/python
## cpu model: Intel(R) Core(TM) i7-4650U CPU @ 1.70GHz
## parameters: loop=1000000, cycle=10, extra=1
## (#1) real (total = user + sys)
encrypt() 3.0950 3.0900 3.0800 0.0100
scrumble_uint32() 1.5587 1.5500 1.5500 0.0000
## (#2) real (total = user + sys)
encrypt() 3.0433 3.0400 3.0300 0.0100
scrumble_uint32() 1.5566 1.5500 1.5500 0.0000
## (#3) real (total = user + sys)
encrypt() 3.0792 3.0700 3.0700 0.0000
scrumble_uint32() 1.6038 1.6100 1.6000 0.0100
## (#4) real (total = user + sys)
encrypt() 3.4402 3.4300 3.4300 0.0000
scrumble_uint32() 1.6201 1.6200 1.6100 0.0100
## (#5) real (total = user + sys)
encrypt() 3.3224 3.3100 3.3000 0.0100
scrumble_uint32() 1.6612 1.6600 1.6600 0.0000
## (#6) real (total = user + sys)
encrypt() 3.2873 3.2700 3.2700 0.0000
scrumble_uint32() 1.7107 1.7200 1.7100 0.0100
## (#7) real (total = user + sys)
encrypt() 3.2692 3.2500 3.2500 0.0000
scrumble_uint32() 1.7424 1.7500 1.7400 0.0100
## (#8) real (total = user + sys)
encrypt() 3.3028 3.2800 3.2800 0.0000
scrumble_uint32() 1.7438 1.7500 1.7400 0.0100
## (#9) real (total = user + sys)
encrypt() 3.3293 3.3200 3.3200 0.0000
scrumble_uint32() 1.7906 1.7900 1.7800 0.0100
## (#10) real (total = user + sys)
encrypt() 3.3338 3.3300 3.3300 0.0000
scrumble_uint32() 1.6762 1.6600 1.6600 0.0000
## (#11) real (total = user + sys)
encrypt() 3.3591 3.3600 3.3500 0.0100
scrumble_uint32() 1.7632 1.7600 1.7600 0.0000
## (#12) real (total = user + sys)
encrypt() 3.4799 3.4800 3.4700 0.0100
scrumble_uint32() 1.7219 1.7100 1.7100 0.0000
## Ignore min & max min cycle max cycle
encrypt() 3.0433 (#2) 3.4799 (#12)
scrumble_uint32() 1.5566 (#2) 1.7906 (#9)
## Average of 10 (=12-2*1) real (total = user + sys)
encrypt() 3.2818 3.2710 3.2680 0.0030
scrumble_uint32() 1.6802 1.6790 1.6740 0.0050
## Ranking real
scrumble_uint32() 1.6802 (100.0) ********************
encrypt() 3.2818 ( 51.2) **********
## Matrix real [01] [02]
[01] scrumble_uint32() 1.6802 100.0 195.3
[02] encrypt() 3.2818 51.2 100.0
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment