SMUCNGPerfAnalyzer.cpp 1.22 KB
Newer Older
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
/*
 * SMUCNGPerfAnalyzer.cpp
 *
 *  Created on: Jul 20, 2019
 *      Author: carla
 */

#include "SMUCNGPerfAnalyzer.h"

SMUCNGPerfAnalyzer::SMUCNGPerfAnalyzer() {

}

SMUCNGPerfAnalyzer::~SMUCNGPerfAnalyzer() {
}

void SMUCNGPerfAnalyzer::printConfig(LOG_LEVELll) {
    LOG_VAR(ll) << "            Window:          " << _window;
    AnalyzerTemplate<AggregatorSensorBase>::printConfig(ll);
}

void SMUCNGPerfAnalyzer::compute(U_Ptr unit) {
	auto inputs = unit->getInputs();
	auto timestamp = getTimestamp(); //ToDo timestamp minus some time...
	vector<reading_t> * _bufferInstructions = _queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::INSTRUCTIONS]]->getName(), timestamp, timestamp, _bufferInstructions, false); //use absolute timestamp
	vector<reading_t> * _bufferClocks =	_queryEngine.querySensor(inputs[_metricToPosition[SMUCSensorBase::CLOCKS]]->getName(), timestamp, timestamp, _bufferClocks, false); //use absolute timestamp
	reading_t clockspersecond;
	bool wascalced = calculateMetricRatio(*(_bufferClocks->begin()),*(_bufferInstructions->begin()), 1, clockspersecond);
	delete _bufferInstructions;
	delete _bufferClocks;
	if(wascalced) {
		auto outputs = unit->getOutputs();
		outputs[0]->storeReading(clockspersecond);
	}
}