forked from vencabkk/opencl-resizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfiler.h
More file actions
executable file
·44 lines (35 loc) · 913 Bytes
/
Profiler.h
File metadata and controls
executable file
·44 lines (35 loc) · 913 Bytes
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
//
// Created by Vaclav Samec on 4/28/15 AD.
// Copyright (c) 2015 Venca. All rights reserved.
//
#pragma once
#include <ctime>
#include <iostream>
#include <unordered_map>
#include <string>
class Profiler
{
public:
static void start(const std::string& name)
{
m_clocks[name] = clock();
}
static void stop(const std::string& name)
{
const auto& clock_curr = m_clocks.find(name);
auto ms = float(clock() - clock_curr->second) / CLOCKS_PER_SEC * 1000.0f;
std::cout << "Elapsed time " << name << ": " << ms << "[ms]" << std::endl;
m_clocks.erase(clock_curr);
}
static clock_t start()
{
return clock();
}
static unsigned long stop(clock_t start)
{
auto ms = float(clock() - start) / CLOCKS_PER_SEC * 1000.0f;
return ms;
}
private:
static std::unordered_map<std::string, clock_t> m_clocks;
};