summaryrefslogtreecommitdiff
path: root/selftest.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-04-18 08:45:37 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-04-18 08:45:37 -0700
commita1e94154bebe17a24d2eed43be7d866e93c061fe (patch)
tree16a4b547e31792a6ad42795236b0e2ca8411b084 /selftest.cpp
parent4938e82795ffa0bebeb5921df84bd3e362ba2f46 (diff)
downloadinfinitytier-a1e94154bebe17a24d2eed43be7d866e93c061fe.tar.gz
infinitytier-a1e94154bebe17a24d2eed43be7d866e93c061fe.zip
Just incorporate the X64 ASM version of Salsa20/12 for X64 platforms. This gives us (for example) 1.5gb/sec encryption on a Core i5 2.8ghz.
Diffstat (limited to 'selftest.cpp')
-rw-r--r--selftest.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/selftest.cpp b/selftest.cpp
index fe0aa933..b7a1cc4d 100644
--- a/selftest.cpp
+++ b/selftest.cpp
@@ -54,6 +54,10 @@
#include "controller/JSONDB.hpp"
+#ifdef ZT_USE_X64_ASM_SALSA2012
+#include "ext/x64-salsa2012-asm/salsa2012.h"
+#endif
+
#ifdef __WINDOWS__
#include <tchar.h>
#endif
@@ -204,6 +208,24 @@ static int testCrypto()
::free((void *)bb);
}
+#ifdef ZT_USE_X64_ASM_SALSA2012
+ std::cout << "[crypto] Benchmarking Salsa20/12 fast x64 ASM... "; std::cout.flush();
+ {
+ unsigned char *bb = (unsigned char *)::malloc(1234567);
+ for(unsigned int i=0;i<1234567;++i)
+ bb[i] = (unsigned char)i;
+ double bytes = 0.0;
+ uint64_t start = OSUtils::now();
+ for(unsigned int i=0;i<200;++i) {
+ zt_salsa2012_amd64_xmm6_xor(bb,bb,1234567,s20TV0Iv,s20TV0Key);
+ bytes += 1234567.0;
+ }
+ uint64_t end = OSUtils::now();
+ std::cout << ((bytes / 1048576.0) / ((double)(end - start) / 1000.0)) << " MiB/second" << std::endl;
+ ::free((void *)bb);
+ }
+#endif
+
std::cout << "[crypto] Benchmarking Salsa20/20... "; std::cout.flush();
{
unsigned char *bb = (unsigned char *)::malloc(1234567);