Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
9aa96d2e
Commit
9aa96d2e
authored
Jul 09, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
8a6145c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
30 deletions
+30
-30
go/neo/t/tcpu.py
go/neo/t/tcpu.py
+29
-3
go/neo/t/tzodb.py
go/neo/t/tzodb.py
+1
-27
No files found.
go/neo/t/tcpu.py
View file @
9aa96d2e
...
...
@@ -24,12 +24,38 @@ from __future__ import print_function
import
sys
import
hashlib
import
tzodb
import
zlib
from
zlib
import
crc32
,
adler32
from
os.path
import
dirname
from
golang
import
testing
# adler32 in hashlib interface
class
Adler32Hasher
:
name
=
"adler32"
def
__init__
(
self
):
self
.
h
=
adler32
(
''
)
def
update
(
self
,
data
):
self
.
h
=
adler32
(
data
,
self
.
h
)
def
hexdigest
(
self
):
return
'%08x'
%
(
self
.
h
&
0xffffffff
)
# crc32 in hashlib interface
class
CRC32Hasher
:
name
=
"crc32"
def
__init__
(
self
):
self
.
h
=
crc32
(
''
)
def
update
(
self
,
data
):
self
.
h
=
crc32
(
data
,
self
.
h
)
def
hexdigest
(
self
):
return
'%08x'
%
(
self
.
h
&
0xffffffff
)
# fmtsize formats size in human readable form
_unitv
=
"BKMGT"
# (2^10)^i represents by corresponding char suffix
def
fmtsize
(
size
):
...
...
@@ -77,8 +103,8 @@ def _bench_hasher(b, h, blksize):
i
+=
1
def
bench_adler32
(
b
,
blksize
):
_bench_hasher
(
b
,
tzodb
.
Adler32Hasher
(),
blksize
)
def
bench_crc32
(
b
,
blksize
):
_bench_hasher
(
b
,
tzodb
.
CRC32Hasher
(),
blksize
)
def
bench_adler32
(
b
,
blksize
):
_bench_hasher
(
b
,
Adler32Hasher
(),
blksize
)
def
bench_crc32
(
b
,
blksize
):
_bench_hasher
(
b
,
CRC32Hasher
(),
blksize
)
def
bench_sha1
(
b
,
blksize
):
_bench_hasher
(
b
,
hashlib
.
sha1
(),
blksize
)
...
...
go/neo/t/tzodb.py
View file @
9aa96d2e
...
...
@@ -27,7 +27,7 @@ from ZODB.POSException import POSKeyError
from
ZODB.utils
import
p64
,
u64
import
hashlib
from
zlib
import
crc32
,
adler32
from
tcpu
import
Adler32Hasher
,
CRC32Hasher
import
sys
import
logging
from
time
import
time
...
...
@@ -43,32 +43,6 @@ class NullHasher:
def
hexdigest
(
self
):
return
"00"
# adler32 in hashlib interface
class
Adler32Hasher
:
name
=
"adler32"
def
__init__
(
self
):
self
.
h
=
adler32
(
''
)
def
update
(
self
,
data
):
self
.
h
=
adler32
(
data
,
self
.
h
)
def
hexdigest
(
self
):
return
'%08x'
%
(
self
.
h
&
0xffffffff
)
# crc32 in hashlib interface
class
CRC32Hasher
:
name
=
"crc32"
def
__init__
(
self
):
self
.
h
=
crc32
(
''
)
def
update
(
self
,
data
):
self
.
h
=
crc32
(
data
,
self
.
h
)
def
hexdigest
(
self
):
return
'%08x'
%
(
self
.
h
&
0xffffffff
)
# {} name -> hasher
hashRegistry
=
{
"null"
:
NullHasher
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment