|
Have you seen GetTickCount() ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Depending on precission you may want to look at QueryPerformanceFrequency() and QueryPerformanceCounter()
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Seeing as I have a small class that will give you a TRACE of the time it takes to execute I have posted it.
#if !defined(AFX_CLASSTIMER_H__FAFE8946_4D39_4CB7_921D_0202D60ABE26__INCLUDED_)
#define AFX_CLASSTIMER_H__FAFE8946_4D39_4CB7_921D_0202D60ABE26__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class AFX_EXT_CLASS CClassTimer
{
CClassTimer();
public:
CClassTimer::CClassTimer(CString sTimerName, bool bMessageBox = false);
virtual ~CClassTimer();
virtual void OutputNow(CString sOutput, bool bInterim = true);
virtual void SetStart();
virtual void SetInterim();
private:
CString m_sTimerName;
__int64 m_nTimerFrequency;
__int64 m_nStartTick;
__int64 m_nInterimTick;
bool m_bMessageBox;
};
#endif // !defined(AFX_CLASSTIMER_H__FAFE8946_4D39_4CB7_921D_0202D60ABE26__INCLUDED_)
#include "stdafx.h"
#include "ClassTimer.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
CClassTimer::CClassTimer()
{
}
CClassTimer::CClassTimer(CString sTimerName, bool bMessageBox )
: m_sTimerName(sTimerName),
m_bMessageBox(bMessageBox)
{
LARGE_INTEGER Frequency;
Frequency.QuadPart = 0;
if (!QueryPerformanceFrequency(&Frequency))
{
TRACE(_T("Failed to get the high performance counter frequency\n"));
return;
}
m_nTimerFrequency = Frequency.QuadPart;
SetStart();
}
CClassTimer::~CClassTimer()
{
OutputNow(m_sTimerName, false);
}
void CClassTimer::SetStart()
{
LARGE_INTEGER TimerTick;
VERIFY(QueryPerformanceCounter(&TimerTick));
m_nStartTick = TimerTick.QuadPart;
m_nInterimTick = m_nStartTick;
}
void CClassTimer::SetInterim()
{
LARGE_INTEGER TimerTick;
VERIFY(QueryPerformanceCounter(&TimerTick));
m_nInterimTick = TimerTick.QuadPart;
}
void CClassTimer::OutputNow(CString sOutput, bool bInterim )
{
LARGE_INTEGER TimerTick;
QueryPerformanceCounter(&TimerTick);
__int64 nStart = m_nInterimTick;
if (!bInterim)
nStart = m_nStartTick;
CString sPrompt;
sPrompt.Format("%s - %ld us\n",
sOutput,
(ULONG) ((TimerTick.QuadPart - nStart) * 1000000 / m_nTimerFrequency)
);
if (m_bMessageBox)
AfxMessageBox(sPrompt, MB_OK);
TRACE(sPrompt);
if (bInterim)
{
SetInterim();
m_nStartTick += (m_nInterimTick - TimerTick.QuadPart);
}
}
Rip out the bits that you do not like.
Basically if you create an instance of CClassTimer at the top of the function. When the function exits it will trace out how long it took.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
|
As long as you can run your program in the visual studio development emvironment, why not use the Profiler? It does a better job than doing gettime(), and is really easy to use. (Look in the Help.)
But on one of my PCs at work, the profiler refuses to run for some reason.
|
|
|
|
|
Hi,
For a project I need to show scheduled items on a timeline(like a Gantt-chart)in a dialog.
I have been searching the web now for a few days but could not find anything useful.
Found only one article that could help me but the code supplied was incomplete (missing lib-file)(article "CTimelineEditor" on Codeguru, author:Jeffrey M. Barber)
Cannot believe I am the first one encountering this 'challenge'.
Can anyone please help me finding a solution for my problem?
thanks in advance,
|
|
|
|
|
I would use Chris Maunder's MFCGridCtrl class (found here on CP). It's very modifiable. I was thinking of deriving a class from it just for that purpose that could show timelines for various items.
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Hi
What function do i need to run an exe program. I need to call another exe program from my Visual C prog.
Thanks
|
|
|
|
|
try ShellExecute()
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
|
There's also CreateProcess() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thank you!
I think i have to use this method because I can't find the ShellExecute()function in Embedded C++, which I use.
|
|
|
|
|
WinExec() most Simple
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi everybody,
here's a newbie one for y'all:
I was hoping that I'd be able to create an instance of CMap using very simplistic keys with something like:
CMap< int, int&, CMyClass, CMyClass& > m_myMap;
But I get a "'operator =' function is unavailable" error from the compiler. Is this because I have to use keys that are objects of a class, or what?
Best regards,
Håkan Olsson
------------------------------------
Håkan Olsson, M. Sc.
Technical Project Manager
Airborne Hydrography AB, Sweden
http://www.airbornehydro.com
NOTE: All standpoints, opinions, suggestions etc in the above stands for me and me alone and are not in any way affiliated with or endorsed by Airborne Hydrography AB.
|
|
|
|
|
It is saying that you need to implement an operator = within CMyClass.
CMyClass& operator =(const CMyClass& right)
{
<p></p>
return *this;
}
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
UHh... OK. I thought that the "= not defined" thing was about CMap member functions not being able to compare keys rather than the objects...?
Anyway, thanks I'll try that!
------------------------------------
Håkan Olsson, M. Sc.
Technical Project Manager
Airborne Hydrography AB, Sweden
http://www.airbornehydro.com
NOTE: All standpoints, opinions, suggestions etc in the above stands for me and me alone and are not in any way affiliated with or endorsed by Airborne Hydrography AB.
|
|
|
|
|
If it was complaining about a compare method it would be "==" not "=".
Mike
|
|
|
|
|
i have a tga file and it has the parts specfied in it that is to be masked.....but since i am only familiar with the LoadImage function,i converted this .tga file to .bmp file.....what i want to know is:
1)is it still possible to mask with the converted bmp image??
2)if the first isnt possibl,then how do i load a .tga file and use the masking option???
plz help!!!!!
|
|
|
|
|
How can we trap errors in Constructors (C++)
Ranjish
|
|
|
|
|
What type of error???
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
what kind of errors ?
( based on Scott Meyers' More Effective C++ )
one problem is that if there are problems when constructing an object, and an exception is thrown, the object will not be destroyed because it is not fully constructed.
one solution, if possible, is to delay the class initialisation after the object is fully created.
Other solution, if the class absolutly needs to create and allocate members in the constructor, is to use auto_ptr pointers instead of ordinary pointers ( see above reference for full explanation )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi,
I am a new programmer in C++ and Vb. I have got a dll written in c++ and using that dll in vb. There are three functions in the dll namely
absmov(window,double)
relmov(window,double)
posreq(float *pos)
I have only these infos about the dll. So in vb I declared them as subroutine and passing single for float by ref in posreq which is working just fine but for the others I am passing window handle of the form as window and double value for movement. But it is not working doing nothing. What is the error here. What does this window paparemeter means and how to pass these kind of parameters. Any help will be highly appreciable.
|
|
|
|
|
sangit84 wrote:
absmov(window,double)
Buddy,
actually window is not a predefined datatype or structure, i think creator of Dll has written his own structure or what ever .
i htink you have to ask developer of dll about what window do.
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
OK, never posted here before so please feel free to shout at me if i've committed a cardinal sin or something. If you do not then please could you help with my problem.
1. I know no C or C++
2. My colleague is abroad with no internet
3. He is trying to do some error handling using try() and catch(). However, the C compiler says that it doesn't understand the function try(). Does he need to put something in include or something?
Thank you so much in advance if you can help.
Cheers
|
|
|
|
|
If its C and not C++ then use Structured Exception Handling. You can search on Google and MSDN for more information about it.
Try, Catch, Throw exception handling mechanism used in C++ and not in C.
I hope this helps
Have a great day ahead!
Regards,
Sohail Kadiwala
(My Blog - http://blogs.wdevs.com/sohail/[^])
modified 21-Apr-21 21:01pm.
|
|
|
|