⚲
Project
General
Profile
Sign in
Register
Home
Projects
Search
:
ndn-cxx
All Projects
NFD
»
ndn-cxx
Overview
Activity
Roadmap
Issues
Wiki
Download (1.36 KB)
Bug #1589
ยป sign-bench.cpp
KeyChain::sign benchmark tool -
Junxiao Shi
, 05/10/2014 11:29 PM
// ndn-cxx KeyChain::sign benchmark tool
//
// Compile with:
// (OSX only) export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
// g++ -o sign-bench sign-bench.cpp `pkg-config --libs --cflags libndn-cxx`
//
// HOW TO USE
// 1. edit ~/.ndn/client.conf to choose between file or osx-keychain TPM
// (osx-keychain TPM is available on GUI mode only)
// 2. install a default certificate
// (after choosing correct TPM)
// 3. run this benchmark
// If "sign-bench wants to sign using key" popup appears, click [Always Allow],
// and rerun the benchmark.
#include
<ndn-cxx/security/key-chain.hpp>
using
namespace
ndn
;
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
2
)
{
std
::
cout
<<
"sign-bench iterations"
<<
std
::
endl
;
return
1
;
}
int
nIterations
=
atoi
(
argv
[
1
]);
static
const
size_t
PAYLOAD_SIZE
=
4096
;
uint8_t
content
[
PAYLOAD_SIZE
];
Data
data
(
"ndn:/"
);
data
.
setContent
(
content
,
sizeof
(
content
));
KeyChain
keyChain
;
time
::
steady_clock
::
TimePoint
t1
=
time
::
steady_clock
::
now
();
for
(
int
i
=
0
;
i
<
nIterations
;
++
i
)
{
keyChain
.
sign
(
data
);
}
time
::
steady_clock
::
TimePoint
t2
=
time
::
steady_clock
::
now
();
std
::
cout
<<
"KeyChain::sign payloadSize="
<<
PAYLOAD_SIZE
<<
" nIterations="
<<
nIterations
<<
" duration="
<<
time
::
duration_cast
<
time
::
milliseconds
>
(
t2
-
t1
)
<<
std
::
endl
;
return
0
;
}
(1-1/1)
Loading...