c runtime library vs win32 vs MFC

Started by
6 comments, last by cpp_boy 19 years, 1 month ago
Hello. I have a very simple question. How much faster "c runtime library" produced code than code produced using win32 or MFC ? Thanks.
Advertisement
Some things in the C runtime library are faster than other things in the win32 API or MFC. Some things in the win32 API or MFC are faster than other things in the C runtime library.

Which is faster? is not a relevant question to be asked about libraries or APIs in general, because the answer I gave you above is true in all but the most pathological cases. A relevant question to ask would be: I want to do X, what is the most efficient way to do it?

Even then, keep in mind that except for a small number of things, your goal is not performance, but development speed, as an overoptimized program will take longer to develop and might even never reach production. The standard route to do this is to profile first, and optimize only when profiling has shown that there is a need for optimization AND that the gain in performance time is worth the spent on doing the optimization.
Quote:Original post by ToohrVyk
Some things in the C runtime library are faster than other things in the win32 API or MFC. Some things in the win32 API or MFC are faster than other things in the C runtime library.

Which is faster? is not a relevant question to be asked about libraries or APIs in general, because the answer I gave you above is true in all but the most pathological cases. A relevant question to ask would be: I want to do X, what is the most efficient way to do it?

Even then, keep in mind that except for a small number of things, your goal is not performance, but development speed, as an overoptimized program will take longer to develop and might even never reach production. The standard route to do this is to profile first, and optimize only when profiling has shown that there is a need for optimization AND that the gain in performance time is worth the spent on doing the optimization.


The instructor in the "parallel processing lab" stated: C runtime library is the lowest and the fastest layer (above it win32 and above is the MFC).
This specific lab deals with threads/processes in windows. But his statement had nothing to do with threads programming. He told that it will be true in any case, probably LOL ...
Lowest does not mean fastest. First, it depends on the implementation of the C runtime library (and, for instance, the "division" function of the CRT library on PocketPC majorly sucks).

Also, your teacher does probably not take into account the fact that Win32 or MFC do certain things faster than the C runtime library. For instance, the Win32 API provides GDI. Not only is the C runtime library unable to do the same thing as GDI faster than the WIn32 API, it doesn't even provide equivalent functionality.
Quote:Original post by ToohrVyk
Lowest does not mean fastest. First, it depends on the implementation of the C runtime library (and, for instance, the "division" function of the CRT library on PocketPC majorly sucks).

Also, your teacher does probably not take into account the fact that Win32 or MFC do certain things faster than the C runtime library. For instance, the Win32 API provides GDI. Not only is the C runtime library unable to do the same thing as GDI faster than the WIn32 API, it doesn't even provide equivalent functionality.


Ok, but what should I use ? For example, I need to code some stuff. And I want to get the best performence. How would I know what to take from CRT and what to take from win32 API (suppose that this certain "functionality" accessible in both CRT and WIN32)
Quote:
C runtime library is the lowest and the fastest layer

Not if the C runtime is using Win32 system code in it.
Quote:Original post by cpp_boy
Ok, but what should I use ? For example, I need to code some stuff. And I want to get the best performence. How would I know what to take from CRT and what to take from win32 API (suppose that this certain "functionality" accessible in both CRT and WIN32)


A profiler is your best friend. If you have two identical functions that provide the same functionality, test both and use whichever comes out faster.

If the two functions are not identical, choose the one that suits your program best, and the one which is safer.
Thanks guys :)

This topic is closed to new replies.

Advertisement