Browse Source

For curiosity add Salsa20/8 to benchmarks.

Adam Ierymenko 10 years ago
parent
commit
feddd946f9
2 changed files with 18 additions and 0 deletions
  1. 0 0
      node/RemotePath.hpp
  2. 18 0
      selftest.cpp

+ 0 - 0
node/Path.hpp → node/RemotePath.hpp


+ 18 - 0
selftest.cpp

@@ -193,6 +193,24 @@ static int testCrypto()
 	std::cout << "[crypto] Salsa20 SSE: DISABLED" << std::endl;
 #endif
 
+	std::cout << "[crypto] Benchmarking Salsa20/8... "; std::cout.flush();
+	{
+		unsigned char *bb = (unsigned char *)::malloc(1234567);
+		for(unsigned int i=0;i<1234567;++i)
+			bb[i] = (unsigned char)i;
+		Salsa20 s20(s20TV0Key,256,s20TV0Iv,8);
+		double bytes = 0.0;
+		uint64_t start = OSUtils::now();
+		for(unsigned int i=0;i<200;++i) {
+			s20.encrypt(bb,bb,1234567);
+			bytes += 1234567.0;
+		}
+		uint64_t end = OSUtils::now();
+		SHA512::hash(buf1,bb,1234567);
+		std::cout << ((bytes / 1048576.0) / ((double)(end - start) / 1000.0)) << " MiB/second (" << Utils::hex(buf1,16) << ')' << std::endl;
+		::free((void *)bb);
+	}
+
 	std::cout << "[crypto] Benchmarking Salsa20/12... "; std::cout.flush();
 	{
 		unsigned char *bb = (unsigned char *)::malloc(1234567);