summaryrefslogtreecommitdiff
path: root/bench.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2010-06-29 01:11:47 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2010-06-29 01:11:47 +0000
commitde6e367b5b652335d1dc6435b6bbef9b64a748a7 (patch)
tree5907ebc7455b0e90dd38063642c3c2f46595966c /bench.cpp
parentb62a309d5c90c48d416b8a55106d5bb90baf7de7 (diff)
downloadcryptopp-de6e367b5b652335d1dc6435b6bbef9b64a748a7.tar.gz
use GlobalRNG(), improved benchmarking of AuthenticatedSymmetricCipher
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@493 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'bench.cpp')
-rw-r--r--bench.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/bench.cpp b/bench.cpp
index 537caff..cee316c 100644
--- a/bench.cpp
+++ b/bench.cpp
@@ -3,9 +3,9 @@
#define _CRT_SECURE_NO_DEPRECATE
#include "bench.h"
+#include "validate.h"
#include "aes.h"
#include "blumshub.h"
-#include "rng.h"
#include "files.h"
#include "hex.h"
#include "modes.h"
@@ -96,6 +96,7 @@ void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal)
{
const int BUF_SIZE=RoundUpToMultipleOf(2048U, cipher.OptimalBlockSize());
AlignedSecByteBlock buf(BUF_SIZE);
+ GlobalRNG().GenerateBlock(buf, BUF_SIZE);
clock_t start = clock();
unsigned long i=0, blocks=1;
@@ -112,12 +113,19 @@ void BenchMark(const char *name, StreamTransformation &cipher, double timeTotal)
OutputResultBytes(name, double(blocks) * BUF_SIZE, timeTaken);
}
+void BenchMark(const char *name, AuthenticatedSymmetricCipher &cipher, double timeTotal)
+{
+ if (cipher.NeedsPrespecifiedDataLengths())
+ cipher.SpecifyDataLengths(0, cipher.MaxMessageLength(), 0);
+
+ BenchMark(name, static_cast<StreamTransformation &>(cipher), timeTotal);
+}
+
void BenchMark(const char *name, HashTransformation &ht, double timeTotal)
{
const int BUF_SIZE=2048U;
AlignedSecByteBlock buf(BUF_SIZE);
- LC_RNG rng((word32)time(NULL));
- rng.GenerateBlock(buf, BUF_SIZE);
+ GlobalRNG().GenerateBlock(buf, BUF_SIZE);
clock_t start = clock();
unsigned long i=0, blocks=1;
@@ -138,8 +146,7 @@ void BenchMark(const char *name, BufferedTransformation &bt, double timeTotal)
{
const int BUF_SIZE=2048U;
AlignedSecByteBlock buf(BUF_SIZE);
- LC_RNG rng((word32)time(NULL));
- rng.GenerateBlock(buf, BUF_SIZE);
+ GlobalRNG().GenerateBlock(buf, BUF_SIZE);
clock_t start = clock();
unsigned long i=0, blocks=1;
@@ -235,10 +242,10 @@ void BenchmarkAll(double t, double hertz)
cout << "<THEAD><TR><TH>Algorithm<TH>MiB/Second" << cpb << "<TH>Microseconds to<br>Setup Key and IV" << cpk << endl;
cout << "\n<TBODY style=\"background: yellow\">";
- BenchMarkByName2<AuthenticatedSymmetricCipher, StreamTransformation>("AES/GCM", 0, "AES/GCM (2K tables)", MakeParameters(Name::TableSize(), 2048));
- BenchMarkByName2<AuthenticatedSymmetricCipher, StreamTransformation>("AES/GCM", 0, "AES/GCM (64K tables)", MakeParameters(Name::TableSize(), 64*1024));
- BenchMarkByName2<AuthenticatedSymmetricCipher, StreamTransformation>("AES/CCM");
- BenchMarkByName2<AuthenticatedSymmetricCipher, StreamTransformation>("AES/EAX");
+ BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/GCM", 0, "AES/GCM (2K tables)", MakeParameters(Name::TableSize(), 2048));
+ BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/GCM", 0, "AES/GCM (64K tables)", MakeParameters(Name::TableSize(), 64*1024));
+ BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/CCM");
+ BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/EAX");
cout << "\n<TBODY style=\"background: white\">";
BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>("AES/GCM", 0, "GMAC(AES) (2K tables)", MakeParameters(Name::TableSize(), 2048));