sl@0: /* sl@0: * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include "tperformancetest.h" sl@0: #include "symmetric.h" sl@0: #include sl@0: sl@0: #ifndef _DEBUG sl@0: _LIT(KPerfEFormat, "\tPerformance (encryption) : %f us/iteration (%i iterations in %iL us)\r\n"); sl@0: _LIT(KPerfDFormat, "\tPerformance (decryption) : %f us/iteration (%i iterations in %iL us)\r\n"); sl@0: _LIT(KTotalFormat, "\tPerformance (total) : %f us/iteration (%i iterations in %iL us)\r\n"); sl@0: _LIT(KPerfThroughput, "\tThroughput (total): %f MB/s\r\n"); sl@0: _LIT(KPerfThroughputAfterSetup, "\tThroughput after setup: %f MB/s\r\n"); sl@0: _LIT(KPerfEncryptorCreate, "\tPerformance (encryptor create) : %f us/iteration (%i iterations in %iL us)\r\n"); sl@0: _LIT(KPerfDecryptorCreate, "\tPerformance (decryptor create) : %f us/iteration (%i iterations in %iL us)\r\n"); sl@0: _LIT(KDataSize,"\tData input size : %i B\r\n"); sl@0: #endif sl@0: sl@0: CTestAction* CPerformanceTest::NewL(RFs& aFs, sl@0: CConsoleBase& aConsole, sl@0: Output& aOut, sl@0: const TTestActionSpec& aTestActionSpec) sl@0: { sl@0: CTestAction* self = CPerformanceTest::NewLC(aFs, aConsole, sl@0: aOut, aTestActionSpec); sl@0: CleanupStack::Pop(); sl@0: return self; sl@0: } sl@0: sl@0: CTestAction* CPerformanceTest::NewLC(RFs& aFs, sl@0: CConsoleBase& aConsole, sl@0: Output& aOut, sl@0: const TTestActionSpec& aTestActionSpec) sl@0: { sl@0: CPerformanceTest* self = new(ELeave) CPerformanceTest(aFs, aConsole, aOut); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aTestActionSpec); sl@0: return self; sl@0: } sl@0: sl@0: CPerformanceTest::~CPerformanceTest() sl@0: { sl@0: delete iEncryptor; sl@0: delete iDecryptor; sl@0: } sl@0: sl@0: CPerformanceTest::CPerformanceTest(RFs& aFs, sl@0: CConsoleBase& aConsole, sl@0: Output& aOut) sl@0: sl@0: : CCryptoTestAction(aFs, aConsole, aOut) sl@0: {} sl@0: sl@0: void CPerformanceTest::DoPerformPrerequisiteL() sl@0: { sl@0: #ifndef _DEBUG sl@0: TInt err = KErrNone; sl@0: TInt pos = 0; sl@0: TPtrC8 vector = Input::ParseElement(*iBody, KVectorStart, KVectorEnd, pos, err); sl@0: sl@0: DoInputParseL(vector); sl@0: sl@0: CBlockTransformation* encryptor = 0; sl@0: CBlockTransformation* decryptor = 0; sl@0: sl@0: switch (iCipherType) sl@0: { sl@0: case (EDESECB): sl@0: {// Time the length of time it takes to set up the key schedule, sl@0: // save it and add to encrypt time, to be consistent with old API sl@0: // for comparison purposes (old API does both set up and encrypt/decrypt sl@0: // in a single operation). sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalSeconds diff(0); sl@0: const TTimeIntervalSeconds iterationTime(iIterationTime); sl@0: sl@0: encryptor = CDESEncryptor::NewL(iKey->Des()); sl@0: iEncryptIterations = 0; sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: encryptor->Reset(); sl@0: iEncryptIterations++; sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: sl@0: delete encryptor; sl@0: sl@0: decryptor = CDESDecryptor::NewL(iKey->Des()); sl@0: sl@0: diff = 0; sl@0: iDecryptIterations = 0; sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: decryptor->Reset(); sl@0: iDecryptIterations++; sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: sl@0: delete decryptor; sl@0: sl@0: encryptor = CDESEncryptor::NewLC(iKey->Des()); sl@0: decryptor = CDESDecryptor::NewL(iKey->Des()); sl@0: CleanupStack::Pop(encryptor); sl@0: } sl@0: break; sl@0: case(EDESCBC): sl@0: { sl@0: CBlockTransformation* desEncryptor = NULL; sl@0: CBlockTransformation* desDecryptor = NULL; sl@0: sl@0: desEncryptor = CDESEncryptor::NewLC(iKey->Des()); sl@0: encryptor = CModeCBCEncryptor::NewL(desEncryptor, iIV->Des()); sl@0: sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalSeconds diff(0); sl@0: const TTimeIntervalSeconds iterationTime(iIterationTime); sl@0: sl@0: iEncryptIterations = 0; sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: iEncryptIterations++; sl@0: encryptor->Reset(); sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: sl@0: CleanupStack::Pop(1); sl@0: delete encryptor; sl@0: sl@0: desDecryptor = CDESDecryptor::NewLC(iKey->Des()); sl@0: decryptor = CModeCBCDecryptor::NewL(desDecryptor, iIV->Des()); sl@0: sl@0: diff = 0; sl@0: iDecryptIterations = 0; sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: decryptor->Reset(); sl@0: iDecryptIterations++; sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: sl@0: CleanupStack::Pop(1); sl@0: delete decryptor; sl@0: sl@0: desEncryptor = CDESEncryptor::NewLC(iKey->Des()); sl@0: desDecryptor = CDESDecryptor::NewLC(iKey->Des()); sl@0: sl@0: encryptor = CModeCBCEncryptor::NewL(desEncryptor, iIV->Des()); sl@0: CleanupStack::PushL(encryptor); sl@0: decryptor = CModeCBCDecryptor::NewL(desDecryptor, iIV->Des()); sl@0: CleanupStack::Pop(3); sl@0: } sl@0: break; sl@0: case (E3DESECB): sl@0: { sl@0: encryptor = C3DESEncryptor::NewL(iKey->Des()); sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalSeconds diff(0); sl@0: const TTimeIntervalSeconds iterationTime(iIterationTime); sl@0: sl@0: iEncryptIterations = 0; sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: iEncryptIterations++; sl@0: encryptor->Reset(); sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: sl@0: delete encryptor; sl@0: sl@0: diff = 0; sl@0: iDecryptIterations = 0; sl@0: decryptor = C3DESDecryptor::NewL(iKey->Des()); sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: decryptor->Reset(); sl@0: iDecryptIterations++; sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: delete decryptor; sl@0: sl@0: encryptor = C3DESEncryptor::NewLC(iKey->Des()); sl@0: decryptor = C3DESDecryptor::NewL(iKey->Des()); sl@0: CleanupStack::Pop(encryptor); sl@0: } sl@0: break; sl@0: case (E3DESCBC): sl@0: { sl@0: CBlockTransformation* the3DESencryptor = NULL; sl@0: CBlockTransformation* the3DESdecryptor = NULL; sl@0: sl@0: the3DESencryptor = C3DESEncryptor::NewLC(iKey->Des()); sl@0: encryptor = CModeCBCEncryptor::NewL(the3DESencryptor, iIV->Des()); sl@0: sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalSeconds diff(0); sl@0: const TTimeIntervalSeconds iterationTime(iIterationTime); sl@0: sl@0: iEncryptIterations = 0; sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: iEncryptIterations++; sl@0: encryptor->Reset(); sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: sl@0: CleanupStack::Pop(1); sl@0: delete encryptor; sl@0: sl@0: the3DESdecryptor = C3DESDecryptor::NewLC(iKey->Des()); sl@0: decryptor = CModeCBCDecryptor::NewL(the3DESdecryptor, iIV->Des()); sl@0: sl@0: diff = 0; sl@0: iDecryptIterations = 0; sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: decryptor->Reset(); sl@0: iDecryptIterations++; sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: CleanupStack::Pop(1); sl@0: delete decryptor; sl@0: sl@0: the3DESencryptor = C3DESEncryptor::NewLC(iKey->Des()); sl@0: the3DESdecryptor = C3DESDecryptor::NewLC(iKey->Des()); sl@0: sl@0: encryptor = CModeCBCEncryptor::NewL(the3DESencryptor, iIV->Des()); sl@0: CleanupStack::PushL(encryptor); sl@0: decryptor = CModeCBCDecryptor::NewL(the3DESdecryptor, iIV->Des()); sl@0: CleanupStack::Pop(3); sl@0: } sl@0: break; sl@0: case (EAESECB): sl@0: { sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalSeconds diff(0); sl@0: const TTimeIntervalSeconds iterationTime(iIterationTime); sl@0: sl@0: iEncryptIterations = 0; sl@0: encryptor = CAESEncryptor::NewL(iKey->Des()); sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: iEncryptIterations++; sl@0: encryptor->Reset(); sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: delete encryptor; sl@0: sl@0: diff = 0; sl@0: iDecryptIterations = 0; sl@0: decryptor = CAESDecryptor::NewL(iKey->Des()); sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: decryptor->Reset(); sl@0: iDecryptIterations++; sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: delete decryptor; sl@0: sl@0: encryptor = CAESEncryptor::NewLC(iKey->Des()); sl@0: decryptor = CAESDecryptor::NewL(iKey->Des()); sl@0: CleanupStack::Pop(encryptor); sl@0: } sl@0: break; sl@0: case (ERC2ECB): sl@0: { sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalSeconds diff(0); sl@0: const TTimeIntervalSeconds iterationTime(iIterationTime); sl@0: sl@0: iEncryptIterations = 0; sl@0: encryptor = CRC2Encryptor::NewL(iKey->Des(), iEffectiveKeyLen); sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: iEncryptIterations++; sl@0: encryptor->Reset(); sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: delete encryptor; sl@0: sl@0: diff = 0; sl@0: decryptor = CRC2Decryptor::NewL(iKey->Des(), iEffectiveKeyLen); sl@0: iDecryptIterations = 0; sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: decryptor->Reset(); sl@0: iDecryptIterations++; sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: delete decryptor; sl@0: sl@0: encryptor = CRC2Encryptor::NewLC(iKey->Des(), iEffectiveKeyLen); sl@0: decryptor = CRC2Decryptor::NewL(iKey->Des(), iEffectiveKeyLen); sl@0: CleanupStack::Pop(encryptor); sl@0: } sl@0: break; sl@0: case (ERC2CBC): sl@0: { sl@0: CBlockTransformation* theRC2encryptor = NULL; sl@0: CBlockTransformation* theRC2decryptor = NULL; sl@0: sl@0: theRC2encryptor = CRC2Encryptor::NewLC(iKey->Des(), iEffectiveKeyLen); sl@0: encryptor = CModeCBCEncryptor::NewL(theRC2encryptor, iIV->Des()); sl@0: sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalSeconds diff(0); sl@0: const TTimeIntervalSeconds iterationTime(iIterationTime); sl@0: sl@0: iEncryptIterations = 0; sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: iEncryptIterations++; sl@0: encryptor->Reset(); sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: CleanupStack::Pop(1); sl@0: delete encryptor; sl@0: sl@0: diff = 0; sl@0: iDecryptIterations = 0; sl@0: theRC2decryptor = CRC2Decryptor::NewLC(iKey->Des(), iEffectiveKeyLen); sl@0: decryptor = CModeCBCDecryptor::NewL(theRC2decryptor, iIV->Des()); sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: decryptor->Reset(); sl@0: iDecryptIterations++; sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: CleanupStack::Pop(1); sl@0: delete decryptor; sl@0: sl@0: theRC2encryptor = CRC2Encryptor::NewLC(iKey->Des(), iEffectiveKeyLen); sl@0: theRC2decryptor = CRC2Decryptor::NewLC(iKey->Des(), iEffectiveKeyLen); sl@0: sl@0: encryptor = CModeCBCEncryptor::NewL(theRC2encryptor, iIV->Des()); sl@0: CleanupStack::PushL(encryptor); sl@0: decryptor = CModeCBCDecryptor::NewL(theRC2decryptor, iIV->Des()); sl@0: CleanupStack::Pop(3); sl@0: } sl@0: break; sl@0: case (ERC4): sl@0: { sl@0: iEncryptor = CARC4::NewL(*iKey); sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalSeconds diff(0); sl@0: const TTimeIntervalSeconds iterationTime(iIterationTime); sl@0: sl@0: iEncryptIterations = 0; sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: iEncryptIterations++; sl@0: iEncryptor->Reset(); sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: sl@0: diff = 0; sl@0: iDecryptIterations = 0; sl@0: iDecryptor = CARC4::NewL(*iKey); sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: iDecryptor->Reset(); sl@0: iDecryptIterations++; sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: } sl@0: break; sl@0: case (ECipherNull): sl@0: { sl@0: iEncryptor = CNullCipher::NewL(); sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalSeconds diff(0); sl@0: const TTimeIntervalSeconds iterationTime(iIterationTime); sl@0: sl@0: iEncryptIterations = 0; sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: iEncryptIterations++; sl@0: iEncryptor->Reset(); sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: sl@0: diff = 0; sl@0: iDecryptIterations = 0; sl@0: iDecryptor = CNullCipher::NewL(); sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: iDecryptor->Reset(); sl@0: iDecryptIterations++; sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime); sl@0: } sl@0: break; sl@0: sl@0: default: sl@0: { sl@0: ASSERT(0); sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: sl@0: if( encryptor && decryptor ) sl@0: { sl@0: CleanupStack::PushL(encryptor); sl@0: CleanupStack::PushL(decryptor); sl@0: sl@0: CPaddingSSLv3* ePadding = CPaddingSSLv3::NewLC(encryptor->BlockSize()); sl@0: iEncryptor = CBufferedEncryptor::NewL(encryptor, ePadding); sl@0: CleanupStack::Pop(ePadding); sl@0: sl@0: CPaddingSSLv3* dPadding = CPaddingSSLv3::NewLC(decryptor->BlockSize()); sl@0: iDecryptor = CBufferedDecryptor::NewL(decryptor, dPadding); sl@0: CleanupStack::Pop(dPadding); sl@0: CleanupStack::Pop(decryptor); sl@0: CleanupStack::Pop(encryptor); sl@0: } sl@0: sl@0: // clear the default input and output fields and fill with random data sl@0: // since for performance testing we do not care about validating sl@0: // correct output sl@0: delete iInput; sl@0: iInput = NULL; sl@0: iInput = HBufC8::NewMaxL(iRandDataSize); sl@0: TPtr8 tempPtr = iInput->Des(); sl@0: TRandom::Random(tempPtr); sl@0: TBuf<128> tempbuf; sl@0: tempbuf.Format(KDataSize, (iInput->Length())); sl@0: iOut.writeString(tempbuf); sl@0: delete iOutput; sl@0: iOutput = NULL; sl@0: iOutput = HBufC8::NewMaxL(iRandDataSize); sl@0: TPtr8 tempPtr2 = iOutput->Des(); sl@0: TRandom::Random(tempPtr2); sl@0: sl@0: iEResult = HBufC8::NewMaxL(iEncryptor->MaxOutputLength(iInput->Length())); sl@0: iDResult = HBufC8::NewMaxL(iDecryptor->MaxOutputLength(iEResult->Size())); sl@0: #endif sl@0: } sl@0: sl@0: void CPerformanceTest::DoPerformActionL() sl@0: { sl@0: iResult = ETrue; sl@0: #ifndef _DEBUG sl@0: TBuf<128> buf; sl@0: TReal rate = I64REAL(iEncryptorCreateTime.Int64()) / iEncryptIterations; sl@0: buf.Format(KPerfEncryptorCreate, rate, iEncryptIterations, iEncryptorCreateTime.Int64()); sl@0: iOut.writeString(buf); sl@0: sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalSeconds diff(0); sl@0: const TTimeIntervalSeconds iterationTime(iIterationTime); sl@0: sl@0: iEncryptIterations = 0; sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: TPtr8 iEResultTemp(iEResult->Des()); sl@0: iEResultTemp.Zero(); sl@0: sl@0: iEncryptor->Process(*iInput, iEResultTemp); sl@0: iEncryptIterations++; sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: sl@0: TTimeIntervalMicroSeconds time = endTime.MicroSecondsFrom(startTime); sl@0: rate = I64REAL(time.Int64()) / iEncryptIterations; sl@0: buf.Format(KPerfEFormat, rate, iEncryptIterations, time.Int64()); sl@0: iOut.writeString(buf); sl@0: sl@0: rate = (static_cast(iEncryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(time.Int64()) * 1024 * 1024); // Throughput in MB/s sl@0: buf.FillZ(); sl@0: buf.Zero(); sl@0: buf.Format(KPerfThroughputAfterSetup, rate); sl@0: iOut.writeString(buf); sl@0: sl@0: TInt64 totalEncryptTime = time.Int64(); sl@0: totalEncryptTime+=iEncryptorCreateTime.Int64(); sl@0: rate = I64REAL(totalEncryptTime) / iEncryptIterations; sl@0: buf.FillZ(); sl@0: buf.Zero(); sl@0: buf.Format(KTotalFormat, rate, iEncryptIterations, totalEncryptTime); sl@0: iOut.writeString(buf); sl@0: sl@0: rate = (static_cast(iEncryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(totalEncryptTime) * 1024 * 1024); // Throughput in MB/s sl@0: buf.Zero(); sl@0: buf.Format(KPerfThroughput, rate); sl@0: iOut.writeString(buf); sl@0: sl@0: // Test decryption sl@0: rate = I64REAL(iDecryptorCreateTime.Int64()) / iDecryptIterations; sl@0: buf.Format(KPerfDecryptorCreate, rate, iDecryptIterations, iDecryptorCreateTime.Int64()); sl@0: iOut.writeString(buf); sl@0: sl@0: diff = 0; sl@0: iDecryptIterations = 0; sl@0: startTime.UniversalTime(); sl@0: while (diff < iterationTime) sl@0: { sl@0: TPtr8 iDResultTemp(iDResult->Des()); sl@0: iDResultTemp.Zero(); sl@0: iDecryptor->Process(*iOutput, iDResultTemp); sl@0: iDecryptIterations++; sl@0: endTime.UniversalTime(); sl@0: endTime.SecondsFrom(startTime, diff); sl@0: } sl@0: endTime.UniversalTime(); sl@0: sl@0: time = endTime.MicroSecondsFrom(startTime); sl@0: rate = I64REAL(time.Int64()) / iDecryptIterations; sl@0: buf.FillZ(); sl@0: buf.Zero(); sl@0: buf.Format(KPerfDFormat, rate, iDecryptIterations, time.Int64()); sl@0: iOut.writeString(buf); sl@0: sl@0: rate = (static_cast(iDecryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(time.Int64()) * 1024 * 1024); // Throughput in MB/s sl@0: buf.Zero(); sl@0: buf.Format(KPerfThroughputAfterSetup, rate); sl@0: iOut.writeString(buf); sl@0: sl@0: TInt64 totalDecryptTime = time.Int64(); sl@0: totalDecryptTime+=iDecryptorCreateTime.Int64(); sl@0: rate = I64REAL(totalDecryptTime) / iDecryptIterations; sl@0: buf.FillZ(); sl@0: buf.Zero(); sl@0: buf.Format(KTotalFormat, rate, iDecryptIterations, totalDecryptTime); sl@0: iOut.writeString(buf); sl@0: sl@0: rate = (static_cast(iDecryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(totalDecryptTime) * 1024 * 1024); // Throughput in MB/s sl@0: buf.Zero(); sl@0: buf.Format(KPerfThroughput, rate); sl@0: iOut.writeString(buf); sl@0: sl@0: #endif sl@0: } sl@0: