|
At the core, you use the rdtsc x86 instruction. The actual sequence is:
ULARGE_INTEGER cycles;
if (!m_onNT)
_asm cli
_asm
{
pushad
cpuid
rdtsc
mov cycles.HighPart,edx
mov cycles.LowPart,eax
popad
}
if (!m_onNT)
_asm sti
You then calculate the overhead of the base test and then time the tests and do analysis (I throw away the top and bottom 20% of the results and average the rest.) You can also calculate the actual speed of the CPU and convert the cycles into seconds. I only do this if I really need to know the time in seconds, otherwise, I just compare cycles.
There are classes posted in CodeProject to help with all this, though I use my own.
|
|
|
|
|
Shah Shehpori wrote:
but i've read in number of C++ docs that making a function inline is of no guarantee that compiler really makes it inline and it depends on a compiler..
In Visual C++ you can use the __forceinline keyword (which is a Visual C++ specific keyword as the double underscore suggests) to force the compiler to compile it as an inline function, again there are restrictions to this but I don't think that'll be the case for you. You can read further in MSDN.
Edit: Oops sorry it was already suggested above. I guess the force is not with me then.
|
|
|
|
|
What caused WSAECONNRESET error?I'm trying to send some data(jpeg file) to my SMTP server,but at the middle of sending this error happend.Any idea?
Mazy
No sig. available now.
|
|
|
|
|
The SMTP server has disconnected the client.
Kuphryn
|
|
|
|
|
Yes,but why?
Mazy
No sig. available now.
|
|
|
|
|
It means that the server closed the connection.
Maybe the mail was too big...
Lot of servers have restrictions on the size of mails they can receive...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Anders Molin wrote:
Maybe the mail was too big...
Lot of servers have restrictions on the size of mails they can receive...
I don't think so,it happend with small data too. Do you have any other suggestion?
Mazy
No sig. available now.
|
|
|
|
|
Whan does the server tell you just before it hangs up....
it gives you an errorcode lige 505 or something...
And when du you send the data, are you in the right state, and have the server accepted that state?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Anders Molin wrote:
And when du you send the data, are you in the right state, and have the server accepted that state?
I don't knwo what do you mean by this,If I send some .txt data there is no problem,and there is no problem with how much of it,so I don't think there is problem with state.
Anders Molin wrote:
Whan does the server tell you just before it hangs up....
it gives you an errorcode lige 505 or something...
No,Before this error theere is no other error.
Mazy
No sig. available now.
|
|
|
|
|
Is ++i statement in the for loop better than i++?
I have heard so many people said that. They said
it is good for memory management. Could someone
gives me a better explanation?
|
|
|
|
|
The theory is that with a post increment you have to make a copy of the object, increment the original, and then return the copy of the object. With a pre increment, you increment the object and then return it. Thus pre increment saves the need to make a copy of the object.
The good news is that 99.9% of the time, it makes no difference at all. However, the more complicated the objects are (i.e. real objects and not just simple data types), then you can see a performance increase by using pre increment.
It all boils down to this: Unless you have a specific need to use post increment, you should use pre increment. It won't buy you anything most of the time, but once you get in the habit of using it, you don't have to worry about the cases where it does buy you something.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
[quote]It all boils down to this: Unless you have a specific need to use post increment, you should use pre increment. It won't buy you anything most of the time, but once you get in the habit of using it, you don't have to worry about the cases where it does buy you something.[/quote]
Does the above statement applies to all application? or just
when you are using for loop? How about in while loop and all
other situation?
In what situation do we have to use post increment(i++)?
Thanks.
|
|
|
|
|
VW_Red_Jetta wrote:
In what situation do we have to use post increment(i++)?
None. You don't have to use a post (or pre) increment anywhere, but for convenience a common place is when indexing arrays:
char ch = pStr[offset++];
This is functionally the same as:
char ch = pStr[offset];<br />
++offset;
And results in exactly the same code for simple objects.
|
|
|
|
|
I highly recommend ++i over i++.
Kuphryn
|
|
|
|
|
To answer your original question, there is no difference at all. The compiler will optimize away the copy of i that normally gets made in the expression i++ , because it sees that the copy isn't being used.
--Mike--
Eh! Steve!
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
OK, but if you don't use optimization (it can be useful for something), it does matter
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
Not for a simple loop and/or case such as this.
|
|
|
|
|
Hello,
I have a problem with using DLLs...
My main project is written in MSVC++, the DLLs are written in Dev-C++/GCC. Loading the DLLs works fine, as well as calling void functions of the DLLs. Now my problem is that when I try to call a function which doesn't return void (so, for example, an unsigned long), the main program crashes after the call to the DLL...
I tried to make the functions in the DLL and the function prototypes in the main app __stdcall but it doesn't change anything.
The functions are exported in C format (the DLL gets loaded correctly...).
Do you have any idea why a non-void function of a DLL crashes my app? I never hat this problem when making DLLs with MSVC++, only now when compiling them with Dev-C++/GNU-GCC...
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
Okay, WHY do you have to make your DLL in Dev-C++? You have VC++ so why don't you make it in VC++?
If you post your code that calls the DLL function it would be easier to help you!
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
well my question really divides into two:
i wanted to save new pictures from old pictures, and add the time to them.
that's when i got to my first question:
[1] i could only save the new pics as gif and bmp, other formats gave me
invalid parameter. why? and how do i fix it?
then i thought to myself "ok, nevermind, i'll just save it as bmp, and then
open it from a new Bitmap object and save it as another format". - wow, it
actually worked, but then i got to my second question:
[2] i can't delete the temporary bmp file, since it's being used, even when
i used pointer to a bitmap and deleted it, it still couldn't delete the
file. why? and how do i fix it? (i used the DeleteFile function)
can anyone help me about these two questions, or one of them, please!
thanks
|
|
|
|
|
i create an application who should draw five(or another number) of cube with sphere ,but i have a problem with it,it just draw one sphere and one cube and i don't know what.
i has used a vector to store the sphere and the cube that i create.
<br />
<br />
#include "stdafx.h"<br />
#include "OpenGl.h"<br />
#include "creatfoufou.h"<br />
#include "foufou.h"<br />
#include <vector><br />
<br />
#include <math.h><br />
<br />
#ifdef _DEBUG<br />
#undef THIS_FILE<br />
static char THIS_FILE[]=__FILE__;<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
using namespace std;<br />
vector< foufou * > fou_caracter;<br />
<br />
<br />
creatfoufou::creatfoufou()<br />
{<br />
ptrfoufou = new foufou;<br />
<br />
<br />
}<br />
<br />
creatfoufou::~creatfoufou()<br />
{<br />
<br />
}<br />
<br />
void creatfoufou::creatfou(int amount)<br />
{<br />
foufou *newfoufouPtr;<br />
int randomX,randomY,randomZ;<br />
int speed,steer;<br />
<br />
for(int index=0;index<amount;index++)<br />
{<br />
newfoufouPtr = new foufou();<br />
fou_caracter.push_back( newfoufouPtr );<br />
randomX = ( ( 1 + rand( ) % 100 ) - 50 );<br />
randomY =( ( 1 + rand( ) % 100 ) - 50 );<br />
randomZ =( ( 1 + rand( ) % 100) - 50);<br />
<br />
setposition(randomX,randomY,randomZ);<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
void creatfoufou::setposition(int newX, int newY, int newZ)<br />
{<br />
<br />
ptrfoufou->RePaint(newX,newY,newZ);<br />
}<br />
|
|
|
|
|
Do these vectors differ from each other? Check out srand /rand functions.
Regards,
BB
|
|
|
|
|
witch vector?
i will send you the project in your mail
|
|
|
|
|
|
Hello *.*!
I'm just programming a little app with MFC. I wonder if there is a simple control that took my output data but there was only the listbox. It is very sinewy to collect all chars to a single line, delete the \n \l 's an then use the AddString function to put it out.
I need to output to a control in a dialog like with printf:
printf("bla bla");
printf("blubb blah \n"); <- NOW the new line!!
and so on...
Did anyone of you have an idea to solve my problem? But I can't use the win32-console-application since I have to use MFC and dialogs!
Thanks in advance, Jan
|
|
|
|