|
There's a lot more going on besides your program - take a look at the Taks Manager and see how many processes are running on your machine.
The processor time allotted to your program by the OS is varying due to other demands on the system. To get truly repeatable results, you'd have to eliminate every other task consuming processor cycles.
|
|
|
|
|
I think the group could give you a better answer if they knew a little more. Here are some things
I would like to know:
1) How long does the program take?
2) How much is the variation in time?
3) Is it CPU bound? Is it disk bound?
4) How are you measuring the time it takes to run?
I will also make some general comments. If the time varies by less than 10%, I would call that insignificant. Also, if the running time is very small (say under 30 seconds) it is difficult to get accurate measurements. Also, if you run the same program twice in a row, the second run will often take less time because the program is already in memory. What I am trying to say is that if you want accurate timings you need to be very carefully about what you do.
Bob
|
|
|
|
|
I build a release version exe program in MFC for image segmentation.
I start the exe.
I open an image and a child window appears, after the command for segmentation is executed, the time is recorded. Note I use the same setting in each run and stop all irrelevant programs in computer.
I do this operation several times and record time expense for each run.
here are a list of time expense:
first, 2.609s;
second,3.297s;
third, 3.469s;
fourth,3.406s---.
They vary mysteriously!
If I restart this exe, the time for the first run also changes, but the first runs always spend less time than later runs.
If I want to get stable time expense, What should I do to improve my code?
|
|
|
|
|
First, I want to be honest with you, I do not know what is going one. Therefore, what
I am going to suggest is probably wrong. One possibility is that your code makes heavy
use of dynamic memory allocation and that the heap is not in the best of shape. Therefore, later runs take more time.
Another possibility is that the times you are seeing are not quite right. That is, they are only accurate with a second. I am also wondering if it could be machine specific. Does it exhibit this behavior on more than one machine?
By the way, if it was my program, I would not worry about this variation in time. I hope this helps.
Bob
|
|
|
|
|
|
|
|
May i know why only constant static integral types are allowed to be initialised inside struct....
struct A
{
static int x=0;
};
the above code throws error...
but
struct A
{
const static int x=0;
};
works fine...
Please explain...
|
|
|
|
|
|
hi,everyone recent i was study how to use ffmpeg to make a media player,but now i miss a question that how to show a bitmap on dc.
CRect rt;
GetClientRect(&rt);
CClientDC dc(this);
CDC mem;
mem.CreateCompatibleDC(&dc);
CBitmap bp;
bp.CreateBitmap(width,height,1,24,lpbits);
mem.SelectObject(&bp);
dc.StretchBlt(0,0,rt.Width(),rt.Height(),&mem,0,0,width,height,SRCCOPY);
but the code not work
lpbits is pointer to the data of bitmap,"height" is the height of bitmap "width" is the width of bitmap
and the size of one pixel's color is three byte
lpbits height width 24 is the all data we know about this bitmap
can you help me to show the data on DC
|
|
|
|
|
may be lpbits has a bad data.
Try to write it to a file on disk(with .bmp), then open it with Paint, see if it can load it or not.
Hope this can help you
www.logicsims.ir
|
|
|
|
|
thanks,but when i try to write it to a bitmap file i find it is normal,some friends told me this bitmap is not a compatible bitmap .
|
|
|
|
|
try it with CImage class.
IStream* pImageStream;
CreateStreamOnHGlobal(NULL, TRUE, &pImageStream);
...
CImage image;
image.Load(pImageStream);
...
www.logicsims.ir
|
|
|
|
|
oh,i am sorry ,i was work on visual C++ 6.0 and is not have CImage calss
and never used gdi+ before, so can you give me some code
|
|
|
|
|
|
I advise you to use gdal library which is a powerful tool supporting almost all kinds of image formats! You at most spend 2 hour to get acquainted with this library! good luck!
|
|
|
|
|
Okay so long story short I'm doing some string manipulation in order to determine the file format the user would like to save an image as in DirectX. Simple enough.
bool saveToFile(const std::tstring &path)
{
size_t pos = path.find_last_of(_T('.'));
std::tstring extension = path.substr(pos + 1);
D3DXIMAGE_FILEFORMAT fmt;
if(extension == _T("bmp"))
{
fmt = D3DXIFF_BMP;
}
else if(extension == _T("png"))
{
fmt = D3DXIFF_PNG;
}
else if(extension == _T("tga"))
{
fmt = D3DXIFF_TGA;
}
else
{
return false;
}
return true;
}
Problem is, upon debugging this code (scratching my head at why no image is being saved!) I come to the realisation that the test for the extension being "bmp" falls through every time. I've checked the contents of extension and sure enough, it's "bmp" - so why is the test falling through?
I'm fairly certain it's got something to do with std::tstring, which is simply defined like so:
namespace std
{
typedef basic_string< TCHAR > tstring;
}
Any ideas?
|
|
|
|
|
The default comparison of a string class is case sensitive.
You will need to write a traits class for case insensitive comparison.
You might as well use _tcsicmp to do the case insensitive comparison.
And you should be using _splitpath_s to get to the file extension.
|
|
|
|
|
I don't need case-insensitive comparison - the contents of extension is literally the lower case string "bmp" - furthermore, shouldn't the default char_traits be fine? TCHAR is either defined as char or wchar_t , and std::string implements a char_traits specialisation for both of these.
|
|
|
|
|
Hi,
I want to display vertical text.
pDC->DrawText("SV",svRect,DT_TOP|DT_LEFT);
Here i want to display "SV" vertically.
Not Like
S
V
It should display as it as but vertically..We have to turn our head to read the text.
Pls help me
Anu
|
|
|
|
|
You must create a vertical font, and then use it in DrawText():
CFont fontVert;
fontVert.CreateFont(12,
0,
900,
0,
FW_NORMAL,
FALSE,
FALSE,
0,
ARABIC_CHARSET,
OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS,
CLEARTYPE_QUALITY,
DEFAULT_PITCH | FF_ROMAN,
_T("Tahoma"));
www.logicsims.ir
|
|
|
|
|
Hello everybody !
We often see some Window Suspended Animation,then we can't click any Sub-Window,example the button,menu and more.
If I know the window handle ,When I try to use function PostMessage to send "WM_NULL" to the window,it doesn't Suspended Animation.Why is this so?
How can I send window message to suspend other window ?
|
|
|
|
|
Just hazarding a guess:
The WM_NULL message performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore.
WM_NULL[^]
|
|
|
|
|
I have a web browser control inside MFC application
In case of the web server is down I need to show error message different then the usual 404 default error.
In order to do it I use put_innerHTML method, the problem is that in the control i see my content but right click and view source I see the original HTML text and I get javascript errors like 'goBackContainet is undefined'
Any ideas?
Also i want to disable javascript error's messages on this web control, independence on what was configure in the IE settings.
Thanks for any help.
|
|
|
|
|
I am trying to use libraries provided by IBM to write a program that controls the front end client of an AS/400 system. My problem is not with the code itself; I have tried various sample programs and they all do the same thing.
Using Microsoft Visual C++ 2008 Express, I get the error mentioned above in the title:
1>------ Build started: Project: testAS400, Configuration: Debug Win32 ------
1>Linking...
1> Creating library C:\Documents and Settings\seniorda\My Documents\Visual Studio 2008\Projects\testAS400\Debug\testAS400.lib and object C:\Documents and Settings\seniorda\My Documents\Visual Studio 2008\Projects\testAS400\Debug\testAS400.exp
1>ECLSAMPS.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall ECLKeyNotify::NotifyError(class ECLPS *,class ECLErr)" (?NotifyError@ECLKeyNotify@@UAEXPAVECLPS@@VECLErr@@@Z)
1>ECLSAMPS.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall ECLKeyNotify::NotifyStop(class ECLPS *,int)" (?NotifyStop@ECLKeyNotify@@UAEXPAVECLPS@@H@Z)
.
.
.
C:\Documents and Settings\seniorda\My Documents\Visual Studio 2008\Projects\testAS400\Debug\testAS400.exe : fatal error LNK1120: 168 unresolved externals
I have made sure I am using the /MT option, as the documentation says I should. I made sure the library was included in the linker path. I still get the same errors.
The IBM site was supposed to include .MDB files from MSVC 2003, but there are no .MDB files at all, just a makefile from IBM Visualage C++ 2003, which my compiler can not use.
Any ideas would be useful... all the library files I can find are old and I can't find any newer library files on IBM's site. Without working libraries, my program is useless, unless I can figure out Plan B, which is to control via Active X, which is illuded to in IBM's text but not explained or recommended.
Thank you.
-Dan
|
|
|
|