Use `std::chrono::high_resolution_clock` for profiling on Mac (#37280)
Summary:
According to Darwin man-page:
`CLOCK_REALTIME` the system's real time (i.e. wall time) clock, expressed as the amount of time since the Epoch. This is the same as the value returned by `gettimeofday`(2).
I.e. its returns timestamp with microsecond resolution, as can be obvserved by running following small program:
```
#include <sys/time.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
bool conseq_time(clockid_t c) {
struct timespec t1, t2;
clock_gettime(c, &t1);
clock_gettime(c, &t2);
printf("t1={.tv_sec=%ld, .tv_nsec=%ld}\n", t1.tv_sec, t1.tv_nsec);
printf("t2={.tv_sec=%ld, .tv_nsec=%ld}\n", t2.tv_sec, t2.tv_nsec);
bool rc = t1.tv_sec == t2.tv_sec && t1.tv_nsec == t2.tv_nsec;
printf("Two timestamps are %sequal\n", rc ? "" : "not ");
return rc;
}
int main(void) {
printf("using CLOCK_REALTIME\n");
conseq_time(CLOCK_REALTIME);
printf("using CLOCK_MONOTONIC_RAW\n");
conseq_time(CLOCK_MONOTONIC_RAW);
return 0;
}
```
which if compiled outputs something like:
```
using CLOCK_REALTIME
t1={.tv_sec=107519, .tv_nsec=860315000}
t2={.tv_sec=107519, .tv_nsec=860315000}
Two timestamps are equal
using CLOCK_MONOTONIC_RAW
t1={.tv_sec=107520, .tv_nsec=954297363}
t2={.tv_sec=107520, .tv_nsec=954297426}
Two timestamps are not equal
```
But why do it, if all this platform specific logic is already nicely abstracted in `std::chrono::`:
https://github.com/llvm/llvm-project/blob/master/libcxx/src/chrono.cpp#L117
Pull Request resolved: https://github.com/pytorch/pytorch/pull/37280
Differential Revision: D21246608
Pulled By: malfet
fbshipit-source-id: 6beada30657a2720000e34214b1348112e55be50