Home » Source Code » » Test.cpp

Test.cpp ( File view )

From:
  • By 2010-08-24
  • View(s):3
  • Download(s):0
  • Point(s): 1
			
#include "stdafx.h"
#include "PreciseTimer.h"

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string Int64ToString(__int64 const& ri64, int iRadix=10)
{

	bool bNeg = (ri64 < 0);
	__int64 i64 = ri64;
	string ostrRes;
	bool bSpecial = false;
	if(true == bNeg)
	{

		i64 = -i64;
		if(i64 < 0)
			//Special case number -9223372036854775808 or 0x8000000000000000
			bSpecial = true;
		ostrRes.append(1, '-');
	
}
	int iR;
	do
	{

		iR = i64 % iRadix;
		if(true == bSpecial)
			iR = -iR;
		if(iR < 10)
			ostrRes.append(1, '0' + iR);
		else
			ostrRes.append(1, 'A' + iR - 10);
		i64 /= iRadix;
	
}
	while(i64 != 0);
	//Reverse the string
	string::iterator it = ostrRes.begin();
	if(bNeg)
		it++;
	reverse(it, ostrRes.end());
	return ostrRes;

}

int main()
{

	CPreciseTimer oPreciseTimer;
	cout << "Starting!" << endl;
	oPreciseTimer.StartTimer();
	DWORD dwStart = ::GetTickCount();
	::Sleep(5000);
	cout << "Ending!" << endl;
	oPreciseTimer.StopTimer();
	DWORD dwDiff = (::GetTickCount() - dwStart)*1000;
	__int64 i64Diff = oPreciseTimer.GetTime();
	cout << "Diff1 (GetTickCount()) = " << dwDiff << endl;
	cout << "Diff2 (PreciseTimer) = " << Int64ToString(i64Diff) << endl;
	return 0;

}

			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
PreciseTimer.cpp1.32 kB10-11-01 14:48
PreciseTimer.dsp4.50 kB10-11-01 14:56
PreciseTimer.dsw547.00 B10-11-01 14:34
PreciseTimer.h1.49 kB10-12-01 09:44
StdAfx.cpp294.00 B02-05-01 12:34
StdAfx.h693.00 B10-11-01 14:48
Test.cpp1.25 kB10-12-01 09:48
...
Sponsored links

Test.cpp (4.59 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D