| 45 | void OutputResultOperations(const char *name, const char *operation, bool pc, unsigned long iterations, double timeTaken); |
| 46 | |
| 47 | void BenchMarkEncryption(const char *name, PK_Encryptor &key, double timeTotal, bool pc=false) |
| 48 | { |
| 49 | unsigned int len = 16; |
| 50 | SecByteBlock plaintext(len), ciphertext(key.CiphertextLength(len)); |
| 51 | GlobalRNG().GenerateBlock(plaintext, len); |
| 52 | |
| 53 | const clock_t start = clock(); |
| 54 | unsigned int i; |
| 55 | double timeTaken; |
| 56 | for (timeTaken=(double)0, i=0; timeTaken < timeTotal; timeTaken = double(clock() - start) / CLOCK_TICKS_PER_SECOND, i++) |
| 57 | key.Encrypt(GlobalRNG(), plaintext, len, ciphertext); |
| 58 | |
| 59 | OutputResultOperations(name, "Encryption", pc, i, timeTaken); |
| 60 | |
| 61 | if (!pc && key.GetMaterial().SupportsPrecomputation()) |
| 62 | { |
| 63 | key.AccessMaterial().Precompute(16); |
| 64 | BenchMarkEncryption(name, key, timeTotal, true); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | void BenchMarkDecryption(const char *name, PK_Decryptor &priv, PK_Encryptor &pub, double timeTotal) |
| 69 | { |
no test coverage detected