time.h vs Chrono

I've used #include<time.h>, but I've never seen #include<chrono> before and I played with time code last year.
- I've read through the forums
- I've done google searches

... and I'm still stumped. Why would I use chrono?

My code from last year to see how many processes per tick I was getting:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<iostream>
#include<time.h>
#include<conio.h>
#include<windows.h>

using namespace std;

int main(void) {

    clock_t time;
    int delay;
    delay = 1000;
    time = clock();
    int iCounter =0;
    char chTemp;

    cout << "Clocks_per_Sec:" << CLOCKS_PER_SEC << endl;

    do {
        if(clock()-time>delay) { // (CLOCKS_PER_SEC)/2000) {
            cout << "\rFrames: " << iCounter << endl;
            iCounter = 0;
            time = clock();
        } // Sleep(25);
        iCounter++;
    } while(!kbhit());
    chTemp = _getch();
    cout << endl;
    cout << "Press any key to continue ... ";
    do{}while(!kbhit());
    chTemp = _getch();
    return 0;
}
closed account (48T7M4Gy)
The simplest answer is:

https://stackoverflow.com/questions/36095323/what-is-the-difference-between-chrono-and-ctime

<chrono> is the way to go unless you are involved with legacy code.
Well ....

2+ years ago for this and I've never seen chrono, nor auto until today .... I think I woke up in a different parallel universe than the one I went to sleep in last night.

Thank you!
Facilities in <chrono> supersede some, but not all, of the functionality in <ctime>.

For instance, for the code in the first post (measure the processor time used), there is no equivalent functionality in <chrono>; the standard library facility for this continues to be std::clock().

The two are not mutually exclusive; <chrono> is not a drop in replacement for <ctime>
closed account (48T7M4Gy)
And on that last note: http://en.cppreference.com/w/cpp/chrono/c/clock
Topic archived. No new replies allowed.