|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // 時刻取得
9: //
10:
11: // std::chrono は読めないので極力ここに閉じ込める。
12: // 所要実時間の計測は stopwatch.h 参照。
13:
14: #pragma once
15:
16: #include "header.h"
17: #include <chrono>
18:
19: // ホストの現在の UNIX 時刻を [usec] 単位で取得する。
20: inline uint64
21: get_hosttime_usec()
22: {
23: using namespace std::chrono;
24: auto now = system_clock::now().time_since_epoch();
25: auto usec = duration_cast<microseconds>(now).count();
26: return static_cast<uint64>(usec);
27: }
28:
29: // ホストの現在の UNIX 時刻を [sec] 単位で取得する。
30: inline uint64
31: get_hosttime_sec()
32: {
33: using namespace std::chrono;
34: auto now = system_clock::now().time_since_epoch();
35: auto sec = duration_cast<seconds>(now).count();
36: return static_cast<uint64>(sec);
37: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.