Skip to content

Commit

Permalink
Add benchmark for base58 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Apr 3, 2019
1 parent ef4ae11 commit 054c4f1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dateutils==0.6.6
# Unit testing
pytest==4.3.1
pytest-mock==1.10.2
pytest-benchmark==3.2.2
coverage==4.5.3
mock==2.0.0

Expand Down
48 changes: 48 additions & 0 deletions tests/test_benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
import time
from .fixtures import (
Base58,
base58decode,
base58encode,
ripemd160,
base58CheckEncode,
base58CheckDecode,
gphBase58CheckEncode,
gphBase58CheckDecode,
)

wif_base58 = "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ"
wif_hex = "800c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d507a5b8d"
wif_hex_raw = "0c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d"
wif_gphbase85 = "6Mcb23muAxyXaSMhmB6B1mqkvLdWhtuFZmnZsxDczHRv4mL6Y"


def benchmark_base58():
return (base58decode(wif_base58), base58encode(wif_hex))


def benchmark_base58check():
return (base58CheckDecode(wif_base58), base58CheckEncode(0x80, wif_hex_raw))


def benchmark_gphbase58check():
return (gphBase58CheckDecode(wif_gphbase85), gphBase58CheckEncode(wif_hex_raw))


def test_base58(benchmark):
a, b = benchmark(benchmark_base58)
assert a == wif_hex
assert b == wif_base58


def test_base58check(benchmark):
a, b = benchmark(benchmark_base58check)
print(a, b)
assert a == wif_hex_raw
assert b == wif_base58


def test_gphbase58check(benchmark):
a, b = benchmark(benchmark_gphbase58check)
assert a == wif_hex_raw
assert b == wif_gphbase85

0 comments on commit 054c4f1

Please sign in to comment.