Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Core
Tor
Commits
4f60bca1
Commit
4f60bca1
authored
12 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Add benchmark to test onionskin performance.
parent
3c3084e1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/bench.c
+76
-0
76 additions, 0 deletions
src/test/bench.c
with
76 additions
and
0 deletions
src/test/bench.c
+
76
−
0
View file @
4f60bca1
...
...
@@ -15,9 +15,12 @@ const char tor_git_revision[] = "";
#include
"orconfig.h"
#define RELAY_PRIVATE
#define CONFIG_PRIVATE
#include
"or.h"
#include
"onion.h"
#include
"relay.h"
#include
"config.h"
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID)
static
uint64_t
nanostart
;
...
...
@@ -96,6 +99,66 @@ bench_aes(void)
crypto_cipher_free
(
c
);
}
static
void
bench_onion_TAP
(
void
)
{
const
int
iters
=
1
<<
9
;
int
i
;
crypto_pk_t
*
key
,
*
key2
;
uint64_t
start
,
end
;
char
os
[
ONIONSKIN_CHALLENGE_LEN
];
char
or
[
ONIONSKIN_REPLY_LEN
];
crypto_dh_t
*
dh_out
;
key
=
crypto_pk_new
();
key2
=
crypto_pk_new
();
crypto_pk_generate_key_with_bits
(
key
,
1024
);
crypto_pk_generate_key_with_bits
(
key2
,
1024
);
reset_perftime
();
start
=
perftime
();
for
(
i
=
0
;
i
<
iters
;
++
i
)
{
onion_skin_create
(
key
,
&
dh_out
,
os
);
crypto_dh_free
(
dh_out
);
}
end
=
perftime
();
printf
(
"Client-side, part 1: %f msec.
\n
"
,
NANOCOUNT
(
start
,
end
,
iters
)
/
1e6
);
onion_skin_create
(
key
,
&
dh_out
,
os
);
start
=
perftime
();
for
(
i
=
0
;
i
<
iters
;
++
i
)
{
char
key_out
[
CPATH_KEY_MATERIAL_LEN
];
onion_skin_server_handshake
(
os
,
key
,
NULL
,
or
,
key_out
,
sizeof
(
key_out
));
}
end
=
perftime
();
printf
(
"Server-side, key guessed right: %f msec
\n
"
,
NANOCOUNT
(
start
,
end
,
iters
)
/
1e6
);
start
=
perftime
();
for
(
i
=
0
;
i
<
iters
;
++
i
)
{
char
key_out
[
CPATH_KEY_MATERIAL_LEN
];
onion_skin_server_handshake
(
os
,
key2
,
key
,
or
,
key_out
,
sizeof
(
key_out
));
}
end
=
perftime
();
printf
(
"Server-side, key guessed wrong: %f msec.
\n
"
,
NANOCOUNT
(
start
,
end
,
iters
)
/
1e6
);
start
=
perftime
();
for
(
i
=
0
;
i
<
iters
;
++
i
)
{
crypto_dh_t
*
dh
;
char
key_out
[
CPATH_KEY_MATERIAL_LEN
];
int
s
;
dh
=
crypto_dh_dup
(
dh_out
);
s
=
onion_skin_client_handshake
(
dh
,
or
,
key_out
,
sizeof
(
key_out
));
tor_assert
(
s
==
0
);
}
end
=
perftime
();
printf
(
"Client-side, part 2: %f msec.
\n
"
,
NANOCOUNT
(
start
,
end
,
iters
)
/
1e6
);
crypto_pk_free
(
key
);
}
static
void
bench_cell_aes
(
void
)
{
...
...
@@ -261,6 +324,7 @@ typedef struct benchmark_t {
static
struct
benchmark_t
benchmarks
[]
=
{
ENT
(
dmap
),
ENT
(
aes
),
ENT
(
onion_TAP
),
ENT
(
cell_aes
),
ENT
(
cell_ops
),
{
NULL
,
NULL
,
0
}
...
...
@@ -286,6 +350,8 @@ main(int argc, const char **argv)
int
i
;
int
list
=
0
,
n_enabled
=
0
;
benchmark_t
*
b
;
char
*
errmsg
;
or_options_t
*
options
;
tor_threads_init
();
...
...
@@ -306,6 +372,16 @@ main(int argc, const char **argv)
reset_perftime
();
crypto_seed_rng
(
1
);
options
=
options_new
();
init_logging
();
options
->
command
=
CMD_RUN_UNITTESTS
;
options
->
DataDirectory
=
tor_strdup
(
""
);
options_init
(
options
);
if
(
set_options
(
options
,
&
errmsg
)
<
0
)
{
printf
(
"Failed to set initial options: %s
\n
"
,
errmsg
);
tor_free
(
errmsg
);
return
1
;
}
for
(
b
=
benchmarks
;
b
->
name
;
++
b
)
{
if
(
b
->
enabled
||
n_enabled
==
0
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment