SMUCNGPerfAnalyzer.cpp 1.36 KB
Newer Older
1
2
3
4
5
6
7
/*
 * SMUCNGPerfAnalyzer.cpp
 *
 *  Created on: Jul 20, 2019
 *      Author: carla
 */

8
#include "../../commonderivedmetrics/DerivedMetrics.h"
9
10
#include "SMUCNGPerfAnalyzer.h"

11
SMUCNGPerfAnalyzer::SMUCNGPerfAnalyzer(const std::string& name): AnalyzerTemplate(name) {
12
13
14
15
16
17

}

SMUCNGPerfAnalyzer::~SMUCNGPerfAnalyzer() {
}

18
19
20
void SMUCNGPerfAnalyzer::printConfig(LOG_LEVEL ll) {
    LOG_VAR(ll) << "           No  Window:          ";
    AnalyzerTemplate<SMUCSensorBase>::printConfig(ll);
21
22
23
24
25
}

void SMUCNGPerfAnalyzer::compute(U_Ptr unit) {
	auto inputs = unit->getInputs();
	auto timestamp = getTimestamp(); //ToDo timestamp minus some time...
26
27
28
29
	vector<reading_t> * bufferInstructions = nullptr;
	bufferInstructions = _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, timestamp, bufferInstructions, false); //use absolute timestamp
	vector<reading_t> * bufferClocks = nullptr;
	bufferClocks =	_queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, timestamp, bufferClocks, false); //use absolute timestamp
30
	reading_t clockspersecond;
31
32
33
	bool wascalced = calculateMetricRatio(*(bufferClocks->begin()),*(bufferInstructions->begin()), 1, clockspersecond);
	delete bufferInstructions;
	delete bufferClocks;
34
35
36
37
38
	if(wascalced) {
		auto outputs = unit->getOutputs();
		outputs[0]->storeReading(clockspersecond);
	}
}