Skip to content

Commit

Permalink
reduce array copying in the util predictor (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
engshahrad authored Nov 19, 2023
1 parent cdd9532 commit 03cf941
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions host-agents/monitoring-agent/predictor.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,14 @@ class predictor
size = utilization_records->size();
if (size == 0)
throw std::logic_error( "Exception: record buffer has size 0!" );
int i = 0;
double records[size];
while (i < size)
{
records[i] = utilization_records->pop();
i++;
}
// calculate the max for the records array
for(i = 0; i < size; ++i) {
if (records[i] > max_util)
{
max_util = records[i];

for (int i = 0; i < size; ++i) {
double util = utilization_records->pop();
if (util > max_util) {
max_util = util;
}
}

prediction = (alpha * max_util + (1-alpha)*old_value ) * (1+ema_margin);
if ( prediction > 100)
prediction = 100;
Expand Down

0 comments on commit 03cf941

Please sign in to comment.