What are the fastest datetime functions to use in C plus plus

Posted on 2009-02-21
Last Modified: 2013-12-14
Im designing a program that uses a date loop and a time loop,.  huge iteration overhead that will be eventually clustered out.  My original program has a separate date and then a time loop, time inside date, and Im thinking of integrating both of them them into one loop, The original program used a bespoke algorihm for calculating date and basically a int to keep track of time.  

Heres the question, whats the fastest c++ time structures algorithms etc to use heres a few ive read about to get an answer started:

in time.h
Calendar Time
time_t ?

CTime and CTimeSpan?


I looked around for some new ideas in the visual studio 8 platform, I know C# uses a datetime structure.


Also How the hell do I get a plus sign to appear on this site, as in C plus plus,  I see it now but when the post goes up it disappears so I jhave to use the word plus???

Question by:TheMoog
    LVL 11

    Expert Comment

    in my point of view the windows API function is the fastest one as it is optimized by the OS vendor.
    and using it can help you bypass the hardware related optimization..

    other vendors of hardware like intel are providing there own library but it is optimize for intel platform only.

    try to use intel c++ compiler.

    hope your problem can be solve.

    LVL 19

    Accepted Solution

    Each one of the functions/objects you mentioned fulfills some purpose but the fastest are probably the functions defined in the C Standard Library time.h as they are least abstracted. The various functions you mentioned are part of different implementations i.e. C, C++, Win32 C++, MFC all of which compile to native code and will be faster than any of the C++ .NET, C# code which is compiled to MSIL and then processed by the JIT.

    The first step would be identify which platform you intend to use to develop your application, i.e. if speed and efficiency are your goal you will probably choose a native code approach preferably as low-level as possible, like C using the methods from time.h, on the other hand if you are interested in ease of development you might go with C++ .NET or C#.

    These are just few thoughts I hope will be useful to you. There is a good article about date and time in C++ at that might be of interest as well.


    Author Comment

    Thats a great post.   Thank you.  Im developing a program for a HPC cluster solution and intent to write it in c/c++ console app as low level as possible.  I then intend to write the GUI written in C# just to operate the dlls and exes, that type of approach.  I want speed and efficiency to be the optimal goal.  Im going to accept your comments as the solution, Im wondering whether you would take a look at another post ill make in a moment on the best memory allocation processes and see if you can make similar comments from that angle.  Thanks again.

    Author Closing Comment

    LVL 19

    Expert Comment

    Thank you very much! I would be happy to take a look at your post and possibly contribute if I can be helpful.

    When selecting the Zones for the post you might be interested in selecting the "C++" zone which has more activity and is frequently checked by several excellent experts.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now