areaDetector  3-5-0
EPICS areaDetector framework
CpuUtil.h
Go to the documentation of this file.
1 //=============================================================================
2 // Copyright 2017 FLIR Integrated Imaging Solutions, Inc. All Rights Reserved.
3 //
4 // This software is the confidential and proprietary information of FLIR
5 // Integrated Imaging Solutions, Inc. ("Confidential Information"). You
6 // shall not disclose such Confidential Information and shall use it only in
7 // accordance with the terms of the license agreement you entered into
8 // with FLIR Integrated Imaging Solutions, Inc. (FLIR).
9 //
10 // FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
11 // SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
12 // IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
13 // PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES
14 // SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
15 // THIS SOFTWARE OR ITS DERIVATIVES.
16 //=============================================================================
17 
18 #pragma once
19 //#include "stdafx.h"
20 #include <Windows.h>
21 #include <string>
22 #include "CpuUtil.h"
23 #include <stdio.h>
24 #include <ostream>
25 #include "Spinnaker.h" //searches include path //local project file
26 #include "SpinGenApi/SpinnakerGenApi.h"
27 #include <math.h>
28 #include <iostream>
29 #include <stdint.h>
30 #include <stdlib.h>
31 #include <fstream>
32 #include <string>
33 #include <time.h>
34 #include <vector>
35 #include <sstream>
36 #include <algorithm>
37 #include <ctime>
38 #include <regex>
39 #include <random>
40 #include <stdio.h>
41 #include <Windows.h>
42 #include <Process.h>
43 
44 using namespace std;
45 //=============================================================================
46 // CPU Usage Helpers
47 //=============================================================================
48 namespace CpuUtil
49 {
50 #ifdef _WIN32
51  struct CpuUsageInfo
52  {
53  CpuUsageInfo()
54  {
55  memset(&kernelStartTime, 0, sizeof(FILETIME));
56  memset(&kernelStopTime, 0, sizeof(FILETIME));
57  memset(&userStartTime, 0, sizeof(FILETIME));
58  memset(&userStopTime, 0, sizeof(FILETIME));
59  memset(&trackingStartTime, 0, sizeof(FILETIME));
60  memset(&trackingStopTime, 0, sizeof(FILETIME));
61  }
62 
63  FILETIME kernelStartTime;
64  FILETIME kernelStopTime;
65  FILETIME userStartTime;
66  FILETIME userStopTime;
67 
68  FILETIME trackingStartTime;
69  FILETIME trackingStopTime;
70 
71  double cpuPercentage;
72  SYSTEMTIME kernelSystemTime, userSystemTime;
73  double kernelTimeMilliseconds;
74  double userTimeMilliseconds;
75  double elapsedTime;
76 
77  };
78 #else
79  struct CpuUsageInfo
80  {
81  bool dummy;
82  };
83 #endif
84 
85  bool StartCpuTracing(CpuUsageInfo* cpuUsage);
86  bool StopCpuTracing(CpuUsageInfo* cpuUsage);
88 }
89 //=============================================================================
90 // Performance counter
91 //=============================================================================
92 namespace PerformanceCounter
93 {
94 
95  void StartPerformanceCounter(); //Starts or resets counter
96  double GetPerformanceCounter();
97 }
98 //=============================================================================
99 // Seconds counter
100 //=============================================================================
101 namespace SecondsCounter
102 {
103  void StartSecondsCounter();
104  int GetSecondsCounter();
105 }
106 //=============================================================================
107 // Type conversion
108 //=============================================================================
109 namespace Conversion
110 {
111  string NumToCString(int number);
112  string NumToCString(double number);
113 }
Definition: CpuUtil.cpp:135
double GetPerformanceCounter()
Definition: CpuUtil.cpp:151
Definition: CpuUtil.h:79
Definition: CpuUtil.cpp:26
string NumToCString(int number)
Definition: CpuUtil.cpp:186
bool dummy
Definition: CpuUtil.h:81
int GetSecondsCounter()
Definition: CpuUtil.cpp:172
std::string GetCpuStats(CpuUsageInfo *cpuUsage)
Definition: CpuUtil.cpp:123
bool StartCpuTracing(CpuUsageInfo *cpuUsage)
Definition: CpuUtil.cpp:113
bool StopCpuTracing(CpuUsageInfo *cpuUsage)
Definition: CpuUtil.cpp:118
void StartPerformanceCounter()
Definition: CpuUtil.cpp:140
Definition: NDFileHDF5Layout.h:42
void StartSecondsCounter()
Definition: CpuUtil.cpp:167
Definition: CpuUtil.cpp:162
Definition: CpuUtil.cpp:184