forked from cpv-project/live-profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
25 lines (22 loc) · 994 Bytes
/
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <LiveProfiler/Analyzers/CpuSampleDebugAnalyzer.hpp>
#include <LiveProfiler/Profiler/Profiler.hpp>
#include <LiveProfiler/Collectors/CpuSampleLinuxCollector.hpp>
#include <LiveProfiler/Interceptors/CpuSampleLinuxSymbolResolveInterceptor.hpp>
int main(int argc, char** argv) {
using namespace LiveProfiler;
if (argc < 3) {
std::cerr << "Usage: ./a.out ProcessName CollectTimeInMilliseconds" << std::endl;
return -1;
}
auto processName = argv[1];
auto collectTime = std::stoi(argv[2]);
Profiler<CpuSampleModel> profiler;
auto collector = profiler.useCollector<CpuSampleLinuxCollector>();
auto analyzer = profiler.addAnalyzer<CpuSampleDebugAnalyzer>();
auto interceptor = profiler.addInterceptor<CpuSampleLinuxSymbolResolveInterceptor>();
collector->filterProcessByName(processName);
std::cout << "collect for " << processName << " in " << collectTime << " ms" << std::endl;
profiler.collectFor(std::chrono::milliseconds(collectTime));
return 0;
}