mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-07 13:03:45 +02:00
More test timing fixes.
This commit is contained in:
parent
ae13983b10
commit
37360d5e2e
1 changed files with 13 additions and 8 deletions
|
@ -1288,7 +1288,7 @@ extern "C" const char *ZTT_benchmarkCrypto()
|
||||||
ctr.init(AES_CTR_TEST_VECTOR_0_IV, tmp);
|
ctr.init(AES_CTR_TEST_VECTOR_0_IV, tmp);
|
||||||
ctr.crypt(tmp, sizeof(tmp));
|
ctr.crypt(tmp, sizeof(tmp));
|
||||||
ctr.finish();
|
ctr.finish();
|
||||||
if (unlikely((++reps & 0xffffU) == 0xffffU)) {
|
if (unlikely((++reps & 0xfffU) == 0xfffU)) {
|
||||||
end = now();
|
end = now();
|
||||||
if ((end - start) > 4000)
|
if ((end - start) > 4000)
|
||||||
break;
|
break;
|
||||||
|
@ -1305,7 +1305,7 @@ extern "C" const char *ZTT_benchmarkCrypto()
|
||||||
gmac.init(tag);
|
gmac.init(tag);
|
||||||
gmac.update(tmp, sizeof(tmp));
|
gmac.update(tmp, sizeof(tmp));
|
||||||
gmac.finish(tag);
|
gmac.finish(tag);
|
||||||
if (unlikely((++reps & 0xffffU) == 0xffffU)) {
|
if (unlikely((++reps & 0xfffU) == 0xfffU)) {
|
||||||
end = now();
|
end = now();
|
||||||
if ((end - start) > 4000)
|
if ((end - start) > 4000)
|
||||||
break;
|
break;
|
||||||
|
@ -1320,17 +1320,22 @@ extern "C" const char *ZTT_benchmarkCrypto()
|
||||||
AES k0(AES_CTR_TEST_VECTOR_0_KEY);
|
AES k0(AES_CTR_TEST_VECTOR_0_KEY);
|
||||||
AES k1(AES_GMAC_VECTOR_0_KEY);
|
AES k1(AES_GMAC_VECTOR_0_KEY);
|
||||||
AES::GMACSIVEncryptor enc(k0, k1);
|
AES::GMACSIVEncryptor enc(k0, k1);
|
||||||
int64_t start = now();
|
int64_t end, start = now();
|
||||||
for (long i = 0; i < 350000; ++i) {
|
unsigned long reps = 0;
|
||||||
enc.init((uint64_t)i, tmp);
|
for (;;) {
|
||||||
|
enc.init((uint64_t)reps, tmp);
|
||||||
enc.update1(tmp, sizeof(tmp));
|
enc.update1(tmp, sizeof(tmp));
|
||||||
enc.finish1();
|
enc.finish1();
|
||||||
enc.update2(tmp, sizeof(tmp));
|
enc.update2(tmp, sizeof(tmp));
|
||||||
enc.finish2();
|
enc.finish2();
|
||||||
|
if (unlikely((++reps & 0xfffU) == 0xfffU)) {
|
||||||
|
end = now();
|
||||||
|
if ((end - start) > 4000)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int64_t end = now();
|
|
||||||
foo = tmp[0]; // prevent optimization
|
foo = tmp[0]; // prevent optimization
|
||||||
ZT_T_PRINTF("%.4f MiB/sec" ZT_EOL_S, ((16384.0 * 350000.0) / 1048576.0) / ((double)(end - start) / 1000.0));
|
ZT_T_PRINTF(" %.4f MiB/sec" ZT_EOL_S, ((16384.0 * (double)reps) / 1048576.0) / ((double)(end - start) / 1000.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue