-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.h
executable file
·49 lines (43 loc) · 1.05 KB
/
profile.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#ifndef PROFILE_H
#define PROFILE_H
#include <chrono>
#include <ctime>
#include <exception>
#include <iostream>
#include <memory>
#include <ratio>
#include <utility>
#ifdef WIN32
#include <Windows.h>
#include <Psapi.h>
#pragma comment(lib, "psapi.lib")
#else
#include <sys/resource>
#include <sys/time.h>
#endif
namespace time_clock {
class ProfilerInstance {
public:
typedef std::chrono::steady_clock SteadyClock;
typedef SteadyClock::time_point TimePoint;
typedef std::chrono::duration<double, std::ratio<1, 1>> DurationTime;
enum class MemoryUnit { KB_, MB_, GB_ };
private:
#define KB / 1024
#define MB KB / 1024
#define GB MB / 1024
private:
static DurationTime duringTime;
static TimePoint startTime;
static TimePoint finishTime;
public:
static void start();
static void finish();
static void dumpDuringTime(std::ostream& os = std::cout);
static double second();
static double millisecond();
static size_t memory(MemoryUnit mu = MemoryUnit::KB_);
};
}
#endif