|
kuphryn wrote:
Ultimate, the better the programming technique including program design, the more efficient the final program will operate. Furthermore, the program file should be smaller while undoubtedly producing the same result.
That sounds like you try to hand-optimize your C code yourself. Unless you're writing time-critical or space-critical code (such as a new Quake III-killing 3D engine, an anti-virus background scanner or a new memory allocator), hand-optimizing is a waste of your own time. Let the compiler writers (like MS, with its mounds of resources, experience, and money) handle the optimizing. Your own optimizations are probably harder for others to read and maintain, as well as possibly confusing the compiler's optimization algorithms.
kuphryn wrote:
I often find myself implementing if/else, while/do while and using bool as a "count" to manage the if/else and loops. In terms of effective programming, is that good practice?
If you're using some funky replacement for an if/else, instead of just using if/else, and the code doesn't fall into a critical type I mentioned earlier, run some performance tests on the code. Then rewrite it using normal if/else structures. If there's no meaningful difference, ditch the funky stuff.
--Mike--
http://home.inreach.com/mdunn/
"Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Thanks guys.
Those are a couple of powerful insights.
Michael Dunn:
Okay. I use bool to as a way to validate if/else and/or while/do whlie loops.
Example:
if (!verify)
...
while(!verify)
...
I agree that it is best to sometime leave it up to C++ itself to optimize the code. However, as programmers, we design the software. It is ultimate up to the programmer to design it in a way that would be best for the job the program performs.
Tim Smith:
Thanks for the clear insight about real world programming. From what you said, I believe the message was it is up to the programmer to manage her/his time wisely in terms of considering which part of an application to put the most time and effort for optimization. The big picture is still about money and getting the product quicker than competitors will still producing a quality software package.
Nicely said!
Kuphryn
|
|
|
|
|
Is there a benchmark for program optimization (execution and processing time)?
Kuphryn
|
|
|
|
|
Well, if you have more cash than you know what to do with, there are packages like Intel's VTune and Rationals Quantify.
You can also use something like PerfTimer to measure performance.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
|
Programs like VTune help you find out where most of the time is being spent.
You can also roll your own timing functions to determine how long specific sections of your code is taking.
Todd Smith
|
|
|
|
|
Thanks.
I believe The Code Project has a class, PerfTime, in its archive that does the job.
Kuphryn
|
|
|
|
|
I'd be very happy if anyone could give me some sort of solution to the following problem:
I am making an .exe file that exports a few function.
The problem I ran into is that if I call malloc inside one of those functions it always returns NULL .
My guess is that no local heap has been initialized, as the C runtime initialization code get's confused by the fact that it's an exe (and therefor no dll entry-point function is called)
If anyone could tell me how to come around this (I need to be able to use the new operator, which calls malloc , which uses _crtheap , but the latter is not exported from the c runtime dll).
Enjoy!
Marc
|
|
|
|
|
|
No, this is not true.
Functions exported by exe files can be used in exactly the same way as those exported by regular dlls
Enjoy!
Marc
|
|
|
|
|
How are you doing to call the exported functions from another executable? Like a normal DLL, loading with LoadLibrary and obtaining the function poitners with GetProcAddress ?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I want to integrate a CButton Object, a simple Button, into the Mainframe of my Application at Runtime.
Thank you for your Help Alex
|
|
|
|
|
I use Chris Maunders CSystemTray class and don't want the taskbar icon or what to say... Not the icon down there beside the clock!
HOw to hide it??
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
So you're using CSystemTray but don't want the system tray icon? The simple answer is don't use CSystemTray, as that is what it is desgined to do. What exactly are you using it for?
________________
David Wulff
http://www.davidwulff.co.uk
"I loathe people who keep dogs. They are cowards who haven't got the guts to bite people themselves" - August Strindberg
|
|
|
|
|
I use it to easy create a tray icon!
But please! Don't tell me to NOT use it!
Then I need to write so much "extra" code! hehe, yes I know what you're thinking!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
Hi All,
How can we create an ActiveX Component in VC++
Sangeetha
|
|
|
|
|
|
I write program and use Crystal report in it and I want run this program to another computer that hasn't crystal report program?
or
I want dll file that need run crystal report file in another computer?
thank for your help
|
|
|
|
|
I know close to nothing about Crystal Reports, but Crystal Decisions website has this article which seems to list the files needed for distribution of apps based on the technology. If this is not what you want there's likely to be more information in that website.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I Write a program and use this program ADO and Datagrid .now i want run this program in anther compuetr.
this program run but don't open dialog's that use them ado and datagrid(need dll)?
and
i want dll that run ado and datagrid ...
thanks for your help
|
|
|
|
|
Hi All,
I want to Create My own AciveX control which should work as teh usual database ActiveX Control.So Please give me the posssible suggessioon to create such a Component
Thanks in Advance
Sangeetha
|
|
|
|
|
Hi
I want a to create a client which will talk to the server using SSL connnection. The purpose of the client is to do several secure transactions from a VC application. I need some pointers as to how i can do this. please help
harish
|
|
|
|
|
Hello there,
I just want to know how you create a new document based on an existing (i.e already open) Document in an MDI. ok, the real problem i am facing is: I am developing an Image processing software. Now when the user opens an image and says for example Image>Convert to Grey Scale, I dont want to touch the original document. I want to create a new document that is a clone of the existing image, and do the operation on that. Then it will be displayed as a separate MDI child Window. Please tell me how to do that
Satya Kiran.
satyakiran_p@yahoo.com
|
|
|
|
|
Given this:
try
{
MyClass->DoSomething();
}
catch (...)
{
cout << "Unknown exception";
}
I am trying to catch a null memory exception (where MyClass is NULL). Is there a specific way to catch this (catch (/*NULL MEMORY*/)), or am I conformed to using the catch all "..." method, or sticking with "if (MyClass!=NULL)"?
|
|
|
|
|
You can also have inside DoSomething a check for this == NULL.
But what you might be looking for is SEH (structured exception handling). VC++ actually has 2 exception systems, C++ and SEH (the exception system of the OS). Look for information on converting SEHs into C++ exceptions. That will get you a closer to what you are looking for.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|