First public contribution.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
20 class Overhead : public BMProgram
22 typedef void (*MeasurementFunc)(TBMResult*, TBMUInt64 aIter);
25 MeasurementFunc iFunc;
28 Measurement(MeasurementFunc aFunc, const TDesC& aName) : iFunc(aFunc), iName(aName) {}
31 Overhead() : BMProgram(_L("Overhead"))
33 virtual TBMResult* Run(TBMUInt64 aIter, TInt* aCount);
35 static TBMResult iResults[];
36 static Measurement iMeasurements[];
38 static void TimerStampOverhead(TBMResult*, TBMUInt64 aIter);
41 Overhead::Measurement Overhead::iMeasurements[] =
43 Measurement(&Overhead::TimerStampOverhead, _L("Getting Timer Stamp Overhead"))
45 TBMResult Overhead::iResults[sizeof(Overhead::iMeasurements)/sizeof(Overhead::iMeasurements[0])];
47 static Overhead overhead;
49 void Overhead::TimerStampOverhead(TBMResult* aResult, TBMUInt64 aIter)
51 for (TBMUInt64 i = 0; i < aIter; ++i)
56 aResult->Cumulate(TBMTicksDelta(t1, t2));
58 // Enable other threads to run
60 TInt prio = BMProgram::SetAbsPriority(RThread(), overhead.iOrigAbsPriority);
61 BMProgram::SetAbsPriority(RThread(), prio);
65 TBMResult* Overhead::Run(TBMUInt64 aIter, TInt* aCount)
67 TInt count = sizeof(iResults)/sizeof(iResults[0]);
69 for (TInt i = 0; i < count; ++i)
71 iResults[i].Reset(iMeasurements[i].iName);
72 iMeasurements[i].iFunc(&iResults[i], aIter);
82 BMProgram* next = bmSuite;
83 bmSuite=(BMProgram*)&overhead;