File: develop.h

package info (click to toggle)
kmc 3.2.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,716 kB
  • sloc: cpp: 38,308; python: 664; makefile: 216; perl: 179; sh: 34
file content (66 lines) | stat: -rw-r--r-- 1,253 bytes parent folder | download | duplicates (3)
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
#ifndef _DEVELOP_H
#define _DEVELOP_H

#include <map>
#include <vector>
#include <iostream>
#include <string>
#include "defs.h"
#include "timer.h"

#ifdef ENABLE_LOGGER




class CLoger
{
	std::map<std::string, std::map<void*, std::vector<double>>> operations;

public:
	static CLoger& GetLogger()
	{
		static CLoger logger;
		return logger;
	}

	void add_to_operators_times(void* addr, double time)
	{
		operations["operators_times"][addr].push_back(time);
	}

	void add_to_wait_for_inputdata(void* addr, double time)
	{
		operations["wait_for_input"][addr].push_back(time);
	}

	void log_operation(const std::string& name, void* addr, double time)
	{
		operations[name][addr].push_back(time);
	}

	void print_stats()
	{
		std::cout << "--operators_times--\n";

		for (auto& oper : operations)
		{
			std::cout << "operation : -----------" << oper.first << "-----------\n";
			for (const auto& _operator : oper.second)
			{
				std::cout << "operator at " << _operator.first << "\n";
				double sum = 0;
				for (const auto& time : _operator.second)
				{
					sum += time;
				}
				std::cout << "time: " << sum << "\nmean: " << (sum / _operator.second.size()) << ", no of entries: " << _operator.second.size() << "\n";
			}
		}

	}
};
#endif


#endif