Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-blobdigest
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-blobdigest
Commits
e8db5894
Commit
e8db5894
authored
Jun 20, 2018
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a trivial benchmark function
parent
68467fcd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
0 deletions
+60
-0
sha256_bench.vtc
src/tests/sha256_bench.vtc
+34
-0
vmod_blobdigest.c
src/vmod_blobdigest.c
+22
-0
vmod_blobdigest.vcc
src/vmod_blobdigest.vcc
+4
-0
No files found.
src/tests/sha256_bench.vtc
0 → 100644
View file @
e8db5894
# looks like -*- vcl -*-
varnishtest "SHA256 bench"
# hmac object
varnish v1 -vcl {
import blobdigest from "${vmod_topbuild}/src/.libs/libvmod_blobdigest.so";
import blob;
backend b { .host = "${bad_ip}"; }
sub vcl_init {
# RFC4231 test cases
new k1 = blob.blob(HEX,
"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b");
new rfc4231t1 = blobdigest.hmac(SHA256, k1.get());
new k6 = blob.blob(HEX,
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.dur = rfc4231t1.hmac_bench(1000000, k6.get());
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
} -run
src/vmod_blobdigest.c
View file @
e8db5894
...
...
@@ -34,6 +34,7 @@
#include "vcl.h"
#include "vas.h"
#include "vsb.h"
#include "vtim.h"
#include "vcc_if.h"
#include "vmod_blobdigest.h"
...
...
@@ -565,6 +566,27 @@ vmod_hmac_hmac(VRT_CTX, struct vmod_blobdigest_hmac *h, VCL_BLOB msg)
h
->
vcl_name
,
"hmac"
);
}
VCL_DURATION
vmod_hmac_hmac_bench
(
VRT_CTX
,
struct
vmod_blobdigest_hmac
*
h
,
VCL_INT
n
,
VCL_BLOB
msg
)
{
double
t0
,
t1
;
uintptr_t
snap
;
if
(
n
<=
0
)
{
ERR
(
ctx
,
"number of rounds must be greater than zero"
);
return
(
-
1
);
}
snap
=
WS_Snapshot
(
ctx
->
ws
);
t0
=
VTIM_mono
();
while
(
n
--
)
{
WS_Reset
(
ctx
->
ws
,
snap
);
(
void
)
vmod_hmac_hmac
(
ctx
,
h
,
msg
);
}
t1
=
VTIM_mono
();
return
(
t1
-
t0
);
}
VCL_VOID
vmod_hmac__fini
(
struct
vmod_blobdigest_hmac
**
hmacp
)
{
...
...
src/vmod_blobdigest.vcc
View file @
e8db5894
...
...
@@ -410,6 +410,10 @@ Example::
return(synth(401));
}
$Method DURATION .hmac_bench(INT n, BLOB msg)
Run `n` rounds of ``.hmac`` and return the net total duration.
$Function BLOB hmacf(ENUM {MD5, SHA1, SHA224, SHA256, SHA384, SHA512, SHA3_224,
SHA3_256, SHA3_384, SHA3_512} hash, BLOB key,
BLOB msg)
...
...
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