1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/crypto/weakcrypto/test/tsymmetric/tperformancetest.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,632 @@
1.4 +/*
1.5 +* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include "tperformancetest.h"
1.23 +#include "symmetric.h"
1.24 +#include <t_output.h>
1.25 +
1.26 +#ifndef _DEBUG
1.27 +_LIT(KPerfEFormat, "\tPerformance (encryption) : %f us/iteration (%i iterations in %iL us)\r\n");
1.28 +_LIT(KPerfDFormat, "\tPerformance (decryption) : %f us/iteration (%i iterations in %iL us)\r\n");
1.29 +_LIT(KTotalFormat, "\tPerformance (total) : %f us/iteration (%i iterations in %iL us)\r\n");
1.30 +_LIT(KPerfThroughput, "\tThroughput (total): %f MB/s\r\n");
1.31 +_LIT(KPerfThroughputAfterSetup, "\tThroughput after setup: %f MB/s\r\n");
1.32 +_LIT(KPerfEncryptorCreate, "\tPerformance (encryptor create) : %f us/iteration (%i iterations in %iL us)\r\n");
1.33 +_LIT(KPerfDecryptorCreate, "\tPerformance (decryptor create) : %f us/iteration (%i iterations in %iL us)\r\n");
1.34 +_LIT(KDataSize,"\tData input size : %i B\r\n");
1.35 +#endif
1.36 +
1.37 +CTestAction* CPerformanceTest::NewL(RFs& aFs,
1.38 + CConsoleBase& aConsole,
1.39 + Output& aOut,
1.40 + const TTestActionSpec& aTestActionSpec)
1.41 + {
1.42 + CTestAction* self = CPerformanceTest::NewLC(aFs, aConsole,
1.43 + aOut, aTestActionSpec);
1.44 + CleanupStack::Pop();
1.45 + return self;
1.46 + }
1.47 +
1.48 +CTestAction* CPerformanceTest::NewLC(RFs& aFs,
1.49 + CConsoleBase& aConsole,
1.50 + Output& aOut,
1.51 + const TTestActionSpec& aTestActionSpec)
1.52 + {
1.53 + CPerformanceTest* self = new(ELeave) CPerformanceTest(aFs, aConsole, aOut);
1.54 + CleanupStack::PushL(self);
1.55 + self->ConstructL(aTestActionSpec);
1.56 + return self;
1.57 + }
1.58 +
1.59 +CPerformanceTest::~CPerformanceTest()
1.60 +{
1.61 + delete iEncryptor;
1.62 + delete iDecryptor;
1.63 +}
1.64 +
1.65 +CPerformanceTest::CPerformanceTest(RFs& aFs,
1.66 + CConsoleBase& aConsole,
1.67 + Output& aOut)
1.68 +
1.69 +: CCryptoTestAction(aFs, aConsole, aOut)
1.70 +{}
1.71 +
1.72 +void CPerformanceTest::DoPerformPrerequisiteL()
1.73 +{
1.74 +#ifndef _DEBUG
1.75 + TInt err = KErrNone;
1.76 + TInt pos = 0;
1.77 + TPtrC8 vector = Input::ParseElement(*iBody, KVectorStart, KVectorEnd, pos, err);
1.78 +
1.79 + DoInputParseL(vector);
1.80 +
1.81 + CBlockTransformation* encryptor = 0;
1.82 + CBlockTransformation* decryptor = 0;
1.83 +
1.84 + switch (iCipherType)
1.85 + {
1.86 + case (EDESECB):
1.87 + {// Time the length of time it takes to set up the key schedule,
1.88 + // save it and add to encrypt time, to be consistent with old API
1.89 + // for comparison purposes (old API does both set up and encrypt/decrypt
1.90 + // in a single operation).
1.91 + TTime startTime;
1.92 + TTime endTime;
1.93 + TTimeIntervalSeconds diff(0);
1.94 + const TTimeIntervalSeconds iterationTime(iIterationTime);
1.95 +
1.96 + encryptor = CDESEncryptor::NewL(iKey->Des());
1.97 + iEncryptIterations = 0;
1.98 + startTime.UniversalTime();
1.99 + while (diff < iterationTime)
1.100 + {
1.101 + encryptor->Reset();
1.102 + iEncryptIterations++;
1.103 + endTime.UniversalTime();
1.104 + endTime.SecondsFrom(startTime, diff);
1.105 + }
1.106 + endTime.UniversalTime();
1.107 + iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.108 +
1.109 + delete encryptor;
1.110 +
1.111 + decryptor = CDESDecryptor::NewL(iKey->Des());
1.112 +
1.113 + diff = 0;
1.114 + iDecryptIterations = 0;
1.115 + startTime.UniversalTime();
1.116 + while (diff < iterationTime)
1.117 + {
1.118 + decryptor->Reset();
1.119 + iDecryptIterations++;
1.120 + endTime.UniversalTime();
1.121 + endTime.SecondsFrom(startTime, diff);
1.122 + }
1.123 + endTime.UniversalTime();
1.124 + iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.125 +
1.126 + delete decryptor;
1.127 +
1.128 + encryptor = CDESEncryptor::NewLC(iKey->Des());
1.129 + decryptor = CDESDecryptor::NewL(iKey->Des());
1.130 + CleanupStack::Pop(encryptor);
1.131 + }
1.132 + break;
1.133 + case(EDESCBC):
1.134 + {
1.135 + CBlockTransformation* desEncryptor = NULL;
1.136 + CBlockTransformation* desDecryptor = NULL;
1.137 +
1.138 + desEncryptor = CDESEncryptor::NewLC(iKey->Des());
1.139 + encryptor = CModeCBCEncryptor::NewL(desEncryptor, iIV->Des());
1.140 +
1.141 + TTime startTime;
1.142 + TTime endTime;
1.143 + TTimeIntervalSeconds diff(0);
1.144 + const TTimeIntervalSeconds iterationTime(iIterationTime);
1.145 +
1.146 + iEncryptIterations = 0;
1.147 + startTime.UniversalTime();
1.148 + while (diff < iterationTime)
1.149 + {
1.150 + iEncryptIterations++;
1.151 + encryptor->Reset();
1.152 + endTime.UniversalTime();
1.153 + endTime.SecondsFrom(startTime, diff);
1.154 + }
1.155 + endTime.UniversalTime();
1.156 + iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.157 +
1.158 + CleanupStack::Pop(1);
1.159 + delete encryptor;
1.160 +
1.161 + desDecryptor = CDESDecryptor::NewLC(iKey->Des());
1.162 + decryptor = CModeCBCDecryptor::NewL(desDecryptor, iIV->Des());
1.163 +
1.164 + diff = 0;
1.165 + iDecryptIterations = 0;
1.166 + startTime.UniversalTime();
1.167 + while (diff < iterationTime)
1.168 + {
1.169 + decryptor->Reset();
1.170 + iDecryptIterations++;
1.171 + endTime.UniversalTime();
1.172 + endTime.SecondsFrom(startTime, diff);
1.173 + }
1.174 + endTime.UniversalTime();
1.175 + iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.176 +
1.177 + CleanupStack::Pop(1);
1.178 + delete decryptor;
1.179 +
1.180 + desEncryptor = CDESEncryptor::NewLC(iKey->Des());
1.181 + desDecryptor = CDESDecryptor::NewLC(iKey->Des());
1.182 +
1.183 + encryptor = CModeCBCEncryptor::NewL(desEncryptor, iIV->Des());
1.184 + CleanupStack::PushL(encryptor);
1.185 + decryptor = CModeCBCDecryptor::NewL(desDecryptor, iIV->Des());
1.186 + CleanupStack::Pop(3);
1.187 + }
1.188 + break;
1.189 + case (E3DESECB):
1.190 + {
1.191 + encryptor = C3DESEncryptor::NewL(iKey->Des());
1.192 + TTime startTime;
1.193 + TTime endTime;
1.194 + TTimeIntervalSeconds diff(0);
1.195 + const TTimeIntervalSeconds iterationTime(iIterationTime);
1.196 +
1.197 + iEncryptIterations = 0;
1.198 + startTime.UniversalTime();
1.199 + while (diff < iterationTime)
1.200 + {
1.201 + iEncryptIterations++;
1.202 + encryptor->Reset();
1.203 + endTime.UniversalTime();
1.204 + endTime.SecondsFrom(startTime, diff);
1.205 + }
1.206 + endTime.UniversalTime();
1.207 + iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.208 +
1.209 + delete encryptor;
1.210 +
1.211 + diff = 0;
1.212 + iDecryptIterations = 0;
1.213 + decryptor = C3DESDecryptor::NewL(iKey->Des());
1.214 + startTime.UniversalTime();
1.215 + while (diff < iterationTime)
1.216 + {
1.217 + decryptor->Reset();
1.218 + iDecryptIterations++;
1.219 + endTime.UniversalTime();
1.220 + endTime.SecondsFrom(startTime, diff);
1.221 + }
1.222 + endTime.UniversalTime();
1.223 + iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.224 + delete decryptor;
1.225 +
1.226 + encryptor = C3DESEncryptor::NewLC(iKey->Des());
1.227 + decryptor = C3DESDecryptor::NewL(iKey->Des());
1.228 + CleanupStack::Pop(encryptor);
1.229 + }
1.230 + break;
1.231 + case (E3DESCBC):
1.232 + {
1.233 + CBlockTransformation* the3DESencryptor = NULL;
1.234 + CBlockTransformation* the3DESdecryptor = NULL;
1.235 +
1.236 + the3DESencryptor = C3DESEncryptor::NewLC(iKey->Des());
1.237 + encryptor = CModeCBCEncryptor::NewL(the3DESencryptor, iIV->Des());
1.238 +
1.239 + TTime startTime;
1.240 + TTime endTime;
1.241 + TTimeIntervalSeconds diff(0);
1.242 + const TTimeIntervalSeconds iterationTime(iIterationTime);
1.243 +
1.244 + iEncryptIterations = 0;
1.245 + startTime.UniversalTime();
1.246 + while (diff < iterationTime)
1.247 + {
1.248 + iEncryptIterations++;
1.249 + encryptor->Reset();
1.250 + endTime.UniversalTime();
1.251 + endTime.SecondsFrom(startTime, diff);
1.252 + }
1.253 + endTime.UniversalTime();
1.254 + iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.255 +
1.256 + CleanupStack::Pop(1);
1.257 + delete encryptor;
1.258 +
1.259 + the3DESdecryptor = C3DESDecryptor::NewLC(iKey->Des());
1.260 + decryptor = CModeCBCDecryptor::NewL(the3DESdecryptor, iIV->Des());
1.261 +
1.262 + diff = 0;
1.263 + iDecryptIterations = 0;
1.264 + startTime.UniversalTime();
1.265 + while (diff < iterationTime)
1.266 + {
1.267 + decryptor->Reset();
1.268 + iDecryptIterations++;
1.269 + endTime.UniversalTime();
1.270 + endTime.SecondsFrom(startTime, diff);
1.271 + }
1.272 + endTime.UniversalTime();
1.273 + iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.274 + CleanupStack::Pop(1);
1.275 + delete decryptor;
1.276 +
1.277 + the3DESencryptor = C3DESEncryptor::NewLC(iKey->Des());
1.278 + the3DESdecryptor = C3DESDecryptor::NewLC(iKey->Des());
1.279 +
1.280 + encryptor = CModeCBCEncryptor::NewL(the3DESencryptor, iIV->Des());
1.281 + CleanupStack::PushL(encryptor);
1.282 + decryptor = CModeCBCDecryptor::NewL(the3DESdecryptor, iIV->Des());
1.283 + CleanupStack::Pop(3);
1.284 + }
1.285 + break;
1.286 + case (EAESECB):
1.287 + {
1.288 + TTime startTime;
1.289 + TTime endTime;
1.290 + TTimeIntervalSeconds diff(0);
1.291 + const TTimeIntervalSeconds iterationTime(iIterationTime);
1.292 +
1.293 + iEncryptIterations = 0;
1.294 + encryptor = CAESEncryptor::NewL(iKey->Des());
1.295 + startTime.UniversalTime();
1.296 + while (diff < iterationTime)
1.297 + {
1.298 + iEncryptIterations++;
1.299 + encryptor->Reset();
1.300 + endTime.UniversalTime();
1.301 + endTime.SecondsFrom(startTime, diff);
1.302 + }
1.303 + endTime.UniversalTime();
1.304 + iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.305 + delete encryptor;
1.306 +
1.307 + diff = 0;
1.308 + iDecryptIterations = 0;
1.309 + decryptor = CAESDecryptor::NewL(iKey->Des());
1.310 + startTime.UniversalTime();
1.311 + while (diff < iterationTime)
1.312 + {
1.313 + decryptor->Reset();
1.314 + iDecryptIterations++;
1.315 + endTime.UniversalTime();
1.316 + endTime.SecondsFrom(startTime, diff);
1.317 + }
1.318 + endTime.UniversalTime();
1.319 + iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.320 + delete decryptor;
1.321 +
1.322 + encryptor = CAESEncryptor::NewLC(iKey->Des());
1.323 + decryptor = CAESDecryptor::NewL(iKey->Des());
1.324 + CleanupStack::Pop(encryptor);
1.325 + }
1.326 + break;
1.327 + case (ERC2ECB):
1.328 + {
1.329 + TTime startTime;
1.330 + TTime endTime;
1.331 + TTimeIntervalSeconds diff(0);
1.332 + const TTimeIntervalSeconds iterationTime(iIterationTime);
1.333 +
1.334 + iEncryptIterations = 0;
1.335 + encryptor = CRC2Encryptor::NewL(iKey->Des(), iEffectiveKeyLen);
1.336 + startTime.UniversalTime();
1.337 + while (diff < iterationTime)
1.338 + {
1.339 + iEncryptIterations++;
1.340 + encryptor->Reset();
1.341 + endTime.UniversalTime();
1.342 + endTime.SecondsFrom(startTime, diff);
1.343 + }
1.344 + endTime.UniversalTime();
1.345 + iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.346 + delete encryptor;
1.347 +
1.348 + diff = 0;
1.349 + decryptor = CRC2Decryptor::NewL(iKey->Des(), iEffectiveKeyLen);
1.350 + iDecryptIterations = 0;
1.351 + startTime.UniversalTime();
1.352 + while (diff < iterationTime)
1.353 + {
1.354 + decryptor->Reset();
1.355 + iDecryptIterations++;
1.356 + endTime.UniversalTime();
1.357 + endTime.SecondsFrom(startTime, diff);
1.358 + }
1.359 + endTime.UniversalTime();
1.360 + iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.361 + delete decryptor;
1.362 +
1.363 + encryptor = CRC2Encryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
1.364 + decryptor = CRC2Decryptor::NewL(iKey->Des(), iEffectiveKeyLen);
1.365 + CleanupStack::Pop(encryptor);
1.366 + }
1.367 + break;
1.368 + case (ERC2CBC):
1.369 + {
1.370 + CBlockTransformation* theRC2encryptor = NULL;
1.371 + CBlockTransformation* theRC2decryptor = NULL;
1.372 +
1.373 + theRC2encryptor = CRC2Encryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
1.374 + encryptor = CModeCBCEncryptor::NewL(theRC2encryptor, iIV->Des());
1.375 +
1.376 + TTime startTime;
1.377 + TTime endTime;
1.378 + TTimeIntervalSeconds diff(0);
1.379 + const TTimeIntervalSeconds iterationTime(iIterationTime);
1.380 +
1.381 + iEncryptIterations = 0;
1.382 + startTime.UniversalTime();
1.383 + while (diff < iterationTime)
1.384 + {
1.385 + iEncryptIterations++;
1.386 + encryptor->Reset();
1.387 + endTime.UniversalTime();
1.388 + endTime.SecondsFrom(startTime, diff);
1.389 + }
1.390 + endTime.UniversalTime();
1.391 + iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.392 + CleanupStack::Pop(1);
1.393 + delete encryptor;
1.394 +
1.395 + diff = 0;
1.396 + iDecryptIterations = 0;
1.397 + theRC2decryptor = CRC2Decryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
1.398 + decryptor = CModeCBCDecryptor::NewL(theRC2decryptor, iIV->Des());
1.399 + startTime.UniversalTime();
1.400 + while (diff < iterationTime)
1.401 + {
1.402 + decryptor->Reset();
1.403 + iDecryptIterations++;
1.404 + endTime.UniversalTime();
1.405 + endTime.SecondsFrom(startTime, diff);
1.406 + }
1.407 + endTime.UniversalTime();
1.408 + iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.409 + CleanupStack::Pop(1);
1.410 + delete decryptor;
1.411 +
1.412 + theRC2encryptor = CRC2Encryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
1.413 + theRC2decryptor = CRC2Decryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
1.414 +
1.415 + encryptor = CModeCBCEncryptor::NewL(theRC2encryptor, iIV->Des());
1.416 + CleanupStack::PushL(encryptor);
1.417 + decryptor = CModeCBCDecryptor::NewL(theRC2decryptor, iIV->Des());
1.418 + CleanupStack::Pop(3);
1.419 + }
1.420 + break;
1.421 + case (ERC4):
1.422 + {
1.423 + iEncryptor = CARC4::NewL(*iKey);
1.424 + TTime startTime;
1.425 + TTime endTime;
1.426 + TTimeIntervalSeconds diff(0);
1.427 + const TTimeIntervalSeconds iterationTime(iIterationTime);
1.428 +
1.429 + iEncryptIterations = 0;
1.430 + startTime.UniversalTime();
1.431 + while (diff < iterationTime)
1.432 + {
1.433 + iEncryptIterations++;
1.434 + iEncryptor->Reset();
1.435 + endTime.UniversalTime();
1.436 + endTime.SecondsFrom(startTime, diff);
1.437 + }
1.438 + endTime.UniversalTime();
1.439 + iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.440 +
1.441 + diff = 0;
1.442 + iDecryptIterations = 0;
1.443 + iDecryptor = CARC4::NewL(*iKey);
1.444 + startTime.UniversalTime();
1.445 + while (diff < iterationTime)
1.446 + {
1.447 + iDecryptor->Reset();
1.448 + iDecryptIterations++;
1.449 + endTime.UniversalTime();
1.450 + endTime.SecondsFrom(startTime, diff);
1.451 + }
1.452 + endTime.UniversalTime();
1.453 + iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.454 + }
1.455 + break;
1.456 + case (ECipherNull):
1.457 + {
1.458 + iEncryptor = CNullCipher::NewL();
1.459 + TTime startTime;
1.460 + TTime endTime;
1.461 + TTimeIntervalSeconds diff(0);
1.462 + const TTimeIntervalSeconds iterationTime(iIterationTime);
1.463 +
1.464 + iEncryptIterations = 0;
1.465 + startTime.UniversalTime();
1.466 + while (diff < iterationTime)
1.467 + {
1.468 + iEncryptIterations++;
1.469 + iEncryptor->Reset();
1.470 + endTime.UniversalTime();
1.471 + endTime.SecondsFrom(startTime, diff);
1.472 + }
1.473 + endTime.UniversalTime();
1.474 + iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.475 +
1.476 + diff = 0;
1.477 + iDecryptIterations = 0;
1.478 + iDecryptor = CNullCipher::NewL();
1.479 + startTime.UniversalTime();
1.480 + while (diff < iterationTime)
1.481 + {
1.482 + iDecryptor->Reset();
1.483 + iDecryptIterations++;
1.484 + endTime.UniversalTime();
1.485 + endTime.SecondsFrom(startTime, diff);
1.486 + }
1.487 + endTime.UniversalTime();
1.488 + iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
1.489 + }
1.490 + break;
1.491 +
1.492 + default:
1.493 + {
1.494 + ASSERT(0);
1.495 + User::Leave(KErrNotSupported);
1.496 + }
1.497 + }
1.498 +
1.499 + if( encryptor && decryptor )
1.500 + {
1.501 + CleanupStack::PushL(encryptor);
1.502 + CleanupStack::PushL(decryptor);
1.503 +
1.504 + CPaddingSSLv3* ePadding = CPaddingSSLv3::NewLC(encryptor->BlockSize());
1.505 + iEncryptor = CBufferedEncryptor::NewL(encryptor, ePadding);
1.506 + CleanupStack::Pop(ePadding);
1.507 +
1.508 + CPaddingSSLv3* dPadding = CPaddingSSLv3::NewLC(decryptor->BlockSize());
1.509 + iDecryptor = CBufferedDecryptor::NewL(decryptor, dPadding);
1.510 + CleanupStack::Pop(dPadding);
1.511 + CleanupStack::Pop(decryptor);
1.512 + CleanupStack::Pop(encryptor);
1.513 + }
1.514 +
1.515 + // clear the default input and output fields and fill with random data
1.516 + // since for performance testing we do not care about validating
1.517 + // correct output
1.518 + delete iInput;
1.519 + iInput = NULL;
1.520 + iInput = HBufC8::NewMaxL(iRandDataSize);
1.521 + TPtr8 tempPtr = iInput->Des();
1.522 + TRandom::Random(tempPtr);
1.523 + TBuf<128> tempbuf;
1.524 + tempbuf.Format(KDataSize, (iInput->Length()));
1.525 + iOut.writeString(tempbuf);
1.526 + delete iOutput;
1.527 + iOutput = NULL;
1.528 + iOutput = HBufC8::NewMaxL(iRandDataSize);
1.529 + TPtr8 tempPtr2 = iOutput->Des();
1.530 + TRandom::Random(tempPtr2);
1.531 +
1.532 + iEResult = HBufC8::NewMaxL(iEncryptor->MaxOutputLength(iInput->Length()));
1.533 + iDResult = HBufC8::NewMaxL(iDecryptor->MaxOutputLength(iEResult->Size()));
1.534 +#endif
1.535 +}
1.536 +
1.537 +void CPerformanceTest::DoPerformActionL()
1.538 +{
1.539 + iResult = ETrue;
1.540 +#ifndef _DEBUG
1.541 + TBuf<128> buf;
1.542 + TReal rate = I64REAL(iEncryptorCreateTime.Int64()) / iEncryptIterations;
1.543 + buf.Format(KPerfEncryptorCreate, rate, iEncryptIterations, iEncryptorCreateTime.Int64());
1.544 + iOut.writeString(buf);
1.545 +
1.546 + TTime startTime;
1.547 + TTime endTime;
1.548 + TTimeIntervalSeconds diff(0);
1.549 + const TTimeIntervalSeconds iterationTime(iIterationTime);
1.550 +
1.551 + iEncryptIterations = 0;
1.552 + startTime.UniversalTime();
1.553 + while (diff < iterationTime)
1.554 + {
1.555 + TPtr8 iEResultTemp(iEResult->Des());
1.556 + iEResultTemp.Zero();
1.557 +
1.558 + iEncryptor->Process(*iInput, iEResultTemp);
1.559 + iEncryptIterations++;
1.560 + endTime.UniversalTime();
1.561 + endTime.SecondsFrom(startTime, diff);
1.562 + }
1.563 + endTime.UniversalTime();
1.564 +
1.565 + TTimeIntervalMicroSeconds time = endTime.MicroSecondsFrom(startTime);
1.566 + rate = I64REAL(time.Int64()) / iEncryptIterations;
1.567 + buf.Format(KPerfEFormat, rate, iEncryptIterations, time.Int64());
1.568 + iOut.writeString(buf);
1.569 +
1.570 + rate = (static_cast<TReal>(iEncryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(time.Int64()) * 1024 * 1024); // Throughput in MB/s
1.571 + buf.FillZ();
1.572 + buf.Zero();
1.573 + buf.Format(KPerfThroughputAfterSetup, rate);
1.574 + iOut.writeString(buf);
1.575 +
1.576 + TInt64 totalEncryptTime = time.Int64();
1.577 + totalEncryptTime+=iEncryptorCreateTime.Int64();
1.578 + rate = I64REAL(totalEncryptTime) / iEncryptIterations;
1.579 + buf.FillZ();
1.580 + buf.Zero();
1.581 + buf.Format(KTotalFormat, rate, iEncryptIterations, totalEncryptTime);
1.582 + iOut.writeString(buf);
1.583 +
1.584 + rate = (static_cast<TReal>(iEncryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(totalEncryptTime) * 1024 * 1024); // Throughput in MB/s
1.585 + buf.Zero();
1.586 + buf.Format(KPerfThroughput, rate);
1.587 + iOut.writeString(buf);
1.588 +
1.589 +// Test decryption
1.590 + rate = I64REAL(iDecryptorCreateTime.Int64()) / iDecryptIterations;
1.591 + buf.Format(KPerfDecryptorCreate, rate, iDecryptIterations, iDecryptorCreateTime.Int64());
1.592 + iOut.writeString(buf);
1.593 +
1.594 + diff = 0;
1.595 + iDecryptIterations = 0;
1.596 + startTime.UniversalTime();
1.597 + while (diff < iterationTime)
1.598 + {
1.599 + TPtr8 iDResultTemp(iDResult->Des());
1.600 + iDResultTemp.Zero();
1.601 + iDecryptor->Process(*iOutput, iDResultTemp);
1.602 + iDecryptIterations++;
1.603 + endTime.UniversalTime();
1.604 + endTime.SecondsFrom(startTime, diff);
1.605 + }
1.606 + endTime.UniversalTime();
1.607 +
1.608 + time = endTime.MicroSecondsFrom(startTime);
1.609 + rate = I64REAL(time.Int64()) / iDecryptIterations;
1.610 + buf.FillZ();
1.611 + buf.Zero();
1.612 + buf.Format(KPerfDFormat, rate, iDecryptIterations, time.Int64());
1.613 + iOut.writeString(buf);
1.614 +
1.615 + rate = (static_cast<TReal>(iDecryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(time.Int64()) * 1024 * 1024); // Throughput in MB/s
1.616 + buf.Zero();
1.617 + buf.Format(KPerfThroughputAfterSetup, rate);
1.618 + iOut.writeString(buf);
1.619 +
1.620 + TInt64 totalDecryptTime = time.Int64();
1.621 + totalDecryptTime+=iDecryptorCreateTime.Int64();
1.622 + rate = I64REAL(totalDecryptTime) / iDecryptIterations;
1.623 + buf.FillZ();
1.624 + buf.Zero();
1.625 + buf.Format(KTotalFormat, rate, iDecryptIterations, totalDecryptTime);
1.626 + iOut.writeString(buf);
1.627 +
1.628 + rate = (static_cast<TReal>(iDecryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(totalDecryptTime) * 1024 * 1024); // Throughput in MB/s
1.629 + buf.Zero();
1.630 + buf.Format(KPerfThroughput, rate);
1.631 + iOut.writeString(buf);
1.632 +
1.633 +#endif
1.634 +}
1.635 +