Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
02e6fb3c
Commit
02e6fb3c
authored
Jun 25, 2015
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypto/sha256: add benchmark.
Signed-off-by:
Rusty Russell
<
rusty@rustcorp.com.au
>
parent
712dc43d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
ccan/crypto/sha256/benchmarks/Makefile
ccan/crypto/sha256/benchmarks/Makefile
+10
-0
ccan/crypto/sha256/benchmarks/double-sha-bench.c
ccan/crypto/sha256/benchmarks/double-sha-bench.c
+23
-0
No files found.
ccan/crypto/sha256/benchmarks/Makefile
0 → 100644
View file @
02e6fb3c
CCANDIR
:=
../../../../
CFLAGS
:=
-Wall
-I
$(CCANDIR)
-O3
-flto
LDFLAGS
:=
-O3
-flto
double-sha-bench
:
double-sha-bench.o ccan-time.o ccan-crypto-sha256.o
ccan-crypto-sha256.o
:
$(CCANDIR)/ccan/crypto/sha256/sha256.c
$(CC)
$(CFLAGS)
-c
-o
$@
$<
ccan-time.o
:
$(CCANDIR)/ccan/time/time.c
$(CC)
$(CFLAGS)
-c
-o
$@
$<
ccan/crypto/sha256/benchmarks/double-sha-bench.c
0 → 100644
View file @
02e6fb3c
/* Bitcoin does a lot of SHA of SHA. Benchmark that. */
#include <ccan/crypto/sha256/sha256.h>
#include <ccan/time/time.h>
#include <stdio.h>
int
main
(
int
argc
,
char
*
argv
[])
{
struct
timeabs
start
;
struct
timerel
diff
;
size_t
i
,
n
;
struct
sha256
h
;
n
=
atoi
(
argv
[
1
]
?
argv
[
1
]
:
"1000000"
);
sha256
(
&
h
,
&
n
,
sizeof
(
n
));
start
=
time_now
();
for
(
i
=
0
;
i
<
n
;
i
++
)
sha256
(
&
h
,
&
h
,
sizeof
(
h
));
diff
=
time_divide
(
time_between
(
time_now
(),
start
),
n
);
printf
(
"Hashing time for %02x%02x%02x%02x%02x%02x... is %llu nsec
\n
"
,
h
.
u
.
u8
[
0
],
h
.
u
.
u8
[
1
],
h
.
u
.
u8
[
2
],
h
.
u
.
u8
[
3
],
h
.
u
.
u8
[
4
],
h
.
u
.
u8
[
5
],
(
unsigned
long
long
)
time_to_nsec
(
diff
));
return
0
;
}
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