Jump to content
  • Advertisement
Sign in to follow this  
cpp_boy

c runtime library vs win32 vs MFC

This topic is 4829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I have a very simple question. How much faster "c runtime library" produced code than code produced using win32 or MFC ? Thanks.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!