-
Notifications
You must be signed in to change notification settings - Fork 0
/
hpx_profiler.h
48 lines (38 loc) · 1.2 KB
/
hpx_profiler.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
// Copyright (c) 2017, Raffaele Solcà
// All rights reserved.
//
// See LICENSE.txt for terms of usage.
#ifndef HPX_PROFILER_H
#define HPX_PROFILER_H
#include <chrono>
#include <deque>
#include <string>
#include <vector>
#include <unistd.h>
#include <hpx/hpx.hpp>
#include "hpx/util/annotated_function.hpp"
#include "profiler.h"
namespace profiler {
class HpxTaskProfiler {
public:
HpxTaskProfiler(std::string task_name, std::string task_group_name)
: task_name_(task_name), task_group_name_(task_group_name), thread_id_start_(getThreadId()),
time_start_(Profiler::getProfiler().getTime()), apex_profiler(task_name.c_str()) {}
~HpxTaskProfiler() {
int thread_id_end = getThreadId();
TimeType time_end = Profiler::getProfiler().getTime();
Profiler::getProfiler().add(task_name_, task_group_name_, thread_id_start_, time_start_,
thread_id_end, time_end);
}
int getThreadId() {
return hpx::get_worker_thread_num();
}
private:
std::string task_name_;
std::string task_group_name_;
int thread_id_start_;
TimeType time_start_;
hpx::util::annotate_function apex_profiler;
};
}
#endif // HPX_PROFILER_H