File: ExpenseLog.h

package info (click to toggle)
openems 0.0.35+dfsg.1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,288 kB
  • sloc: cpp: 40,259; yacc: 580; lex: 350; makefile: 258; sh: 169; ruby: 19
file content (92 lines) | stat: -rw-r--r-- 2,546 bytes parent folder | download | duplicates (2)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;

#define EXPENSE_LOG 0
#define MRD 1000000000

#if EXPENSE_LOG==1

#define EXPENSE_DEFINE \
ExpenseLog EL; \
ExpenseModule* EngineExpense=EL.AddModule("Static Engine Expenses"); \
ExpenseModule* PPExpense=EL.AddModule("Static Post Processing"); \
ExpenseModule* AdrOpExpense=EL.AddModule("Address Operator");
#define EXTERN_EXPENSE_DEFINE extern ExpenseLog EL;
#define ENGINEEXPENSE_DEFINE extern ExpenseModule* EngineExpense;
#define POSTPROCEXPENSE_DEFINE extern ExpenseModule* PPExpense;
#define ADREXPENSE_DEFINE extern ExpenseModule* AdrOpExpense;
#define ENGINEEXPENSE(IA,IM,DA,DM,AS,BO) EngineExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO));
#define POSTPROCEXPENSE(IA,IM,DA,DM,AS,BO) PPExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO));
#define ADRESSEXPENSE(IA,IM,DA,DM,AS,BO) AdrOpExpense->AddOperations((IA),(IM),(DA),(DM),(AS),(BO));
#define EXPENSEPRINT EL.PrintAll(stderr);
#define EXPENSECLEAR EL.ClearAll();
#else

#define EXPENSE_DEFINE
#define EXTERN_EXPENSE_DEFINE
#define ENGINEEXPENSE_DEFINE
#define POSTPROCEXPENSE_DEFINE
#define ADREXPENSE_DEFINE
#define ENGINEEXPENSE(IA,IM,DA,DM,AS,BO)
#define POSTPROCEXPENSE(IA,IM,DA,DM,AS,BO)
#define ADRESSEXPENSE(IA,IM,DA,DM,AS,BO)
#define EXPENSEPRINT
#define EXPENSECLEAR
#endif

class ExpenseModule
{
	friend class ExpenseLog;
public:
	ExpenseModule(const char* moduleName);
	~ExpenseModule();

	void Clear();

	void AddDoubleAdditons(unsigned int number);
	void AddDoubleMultiplications(unsigned int number);

	void AddIntAdditons(unsigned int number);
	void AddIntMultiplications(unsigned int number);

	void AddAssignments(unsigned int number);
	void AddBoolOperations(unsigned int number);

	void AddOperations(unsigned int IntAdd, unsigned int IntMul, unsigned int DoubleAdd, unsigned int DoubleMul, unsigned int Assigns, unsigned int BoolOp);

	void PrintfSelf(FILE* file=stdout);

protected:
	const char* chModuleName;
	unsigned int uiDoubleAdditions;
	unsigned int uiDoubleMultiplications;
	unsigned int uiIntAdditions;
	unsigned int uiIntMultiplications;
	unsigned int uiAssignments;
	unsigned int uiBoolOp;
	unsigned int uiMrdDA;
	unsigned int uiMrdDM;
	unsigned int uiMrdIA;
	unsigned int uiMrdIM;
	unsigned int uiMrdAssign;
	unsigned int uiMrdBO;
};

class ExpenseLog
{
public:
	ExpenseLog(void);
	~ExpenseLog(void);

	ExpenseModule* AddModule(const char* name);
	void PrintAll(FILE *file=stdout);
	void ClearAll();
protected:
	vector<ExpenseModule*> vModules;
};