Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #129 from NanoTools/develop
Browse files Browse the repository at this point in the history
1.5.3
  • Loading branch information
BitDesert authored Aug 26, 2019
2 parents 6e67a1e + dd89a60 commit 087c16c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 34 deletions.
69 changes: 36 additions & 33 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,42 +79,45 @@
//$confAverage = $rpcConfHistory->{'confirmation_stats'}->{'average'}; // average time [ms] of all confirmations
//$confCount = $rpcConfHistory->{'confirmation_stats'}->{'count'}; // number of confirmations retrieved from the node

// remove data older than $timeLimit
usort($confirmations, 'cmpByTime'); // sort array by time value [ms unix time]
$confCompact = []; // new filtered array
$durationTotal = 0; // for average calc
$confAverage = 0; // average confirmation duration
$timeSpan = 0; // full time span of the data [ms]
foreach ($confirmations as $confirmation) {
// only keep data which is later than X ms from latest (highest) value
if ($confirmation->{'time'} >= $confirmations[0]->{'time'} - CONFIRMATION_TIME_LIMIT) {
array_push($confCompact, $confirmation); // add new data
$durationTotal += $confirmation->{'duration'};
} else {
break; // stop iterating once we pass that limit to save time
// check if we have confirmations, otherwise skip
if (!empty($confirmations)) {
// remove data older than $timeLimit
usort($confirmations, 'cmpByTime'); // sort array by time value [ms unix time]
$confCompact = []; // new filtered array
$durationTotal = 0; // for average calc
$confAverage = 0; // average confirmation duration
$timeSpan = 0; // full time span of the data [ms]
foreach ($confirmations as $confirmation) {
// only keep data which is later than X ms from latest (highest) value
if ($confirmation->{'time'} >= $confirmations[0]->{'time'} - CONFIRMATION_TIME_LIMIT) {
array_push($confCompact, $confirmation); // add new data
$durationTotal += $confirmation->{'duration'};
} else {
break; // stop iterating once we pass that limit to save time
}
}
}
$confCount = count($confCompact);
$confCount = count($confCompact);

// calculate duration average and time span, avoid dividing by zero
if ($confCount > 0) {
$confAverage = round($durationTotal / $confCount);
$timeSpan = $confCompact[0]->{'time'} - $confCompact[$confCount - 1]->{'time'}; // first minus last
}
// calculate duration average and time span, avoid dividing by zero
if ($confCount > 0) {
$confAverage = round($durationTotal / $confCount);
$timeSpan = $confCompact[0]->{'time'} - $confCompact[$confCount - 1]->{'time'}; // first minus last
}

// get percentiles directly from the filtered array
usort($confCompact, 'cmpByDuration'); // sort array by duration value
$percentile50 = getConfirmationsDurationPercentile(50, $confCompact); // 50 percentile also called median
$percentile75 = getConfirmationsDurationPercentile(75, $confCompact);
$percentile90 = getConfirmationsDurationPercentile(90, $confCompact);
$percentile95 = getConfirmationsDurationPercentile(95, $confCompact);
$percentile99 = getConfirmationsDurationPercentile(99, $confCompact);

// combine an array with all confirmation info
$confSummary = ['count' => $confCount, 'timeSpan' => $timeSpan, 'average' => $confAverage, 'percentile50' => $percentile50,
'percentile75' => $percentile75, 'percentile90' => $percentile90, 'percentile95' => $percentile95, 'percentile99' => $percentile99, ];
$data->confirmationInfo = $confSummary;
//$data->apiProcTimeConf = round((microtime(true) - $timeStampBefore) * 1000);
// get percentiles directly from the filtered array
usort($confCompact, 'cmpByDuration'); // sort array by duration value
$percentile50 = getConfirmationsDurationPercentile(50, $confCompact); // 50 percentile also called median
$percentile75 = getConfirmationsDurationPercentile(75, $confCompact);
$percentile90 = getConfirmationsDurationPercentile(90, $confCompact);
$percentile95 = getConfirmationsDurationPercentile(95, $confCompact);
$percentile99 = getConfirmationsDurationPercentile(99, $confCompact);

// combine an array with all confirmation info
$confSummary = ['count' => $confCount, 'timeSpan' => $timeSpan, 'average' => $confAverage, 'percentile50' => $percentile50,
'percentile75' => $percentile75, 'percentile90' => $percentile90, 'percentile95' => $percentile95, 'percentile99' => $percentile99, ];
$data->confirmationInfo = $confSummary;
//$data->apiProcTimeConf = round((microtime(true) - $timeStampBefore) * 1000);
}

// -- Get node account balance from nano_node
$rpcNodeAccountBalance = getAccountBalance($ch, $nanoNodeAccount);
Expand Down
2 changes: 1 addition & 1 deletion modules/constants.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

// the project version
define('PROJECT_VERSION', '1.5.2');
define('PROJECT_VERSION', '1.5.3');

// project URL
define('PROJECT_URL', 'https://github.com/NanoTools/nanoNodeMonitor');
Expand Down

0 comments on commit 087c16c

Please sign in to comment.