1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-20 05:42:40 +01:00

Compute average costs more correctly in Multimeter

Summary: Ref T6930. We were dividing total cost by number of samples, but should more accurately divide it by the sum of the sample rates. This produces a more meaningful number.

Test Plan: Saw a more meaningful number in the UI.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6930

Differential Revision: https://secure.phabricator.com/D12655
This commit is contained in:
epriestley 2015-05-04 10:04:27 -07:00
parent 1168a8c0a0
commit e6e0df6aff

View file

@ -56,7 +56,10 @@ final class MultimeterSampleController extends MultimeterController {
$data = queryfx_all( $data = queryfx_all(
$conn, $conn,
'SELECT *, count(*) N, SUM(sampleRate * resourceCost) as totalCost 'SELECT *,
count(*) AS N,
SUM(sampleRate * resourceCost) AS totalCost,
SUM(sampleRate * resourceCost) / SUM(sampleRate) AS averageCost
FROM %T FROM %T
WHERE %Q WHERE %Q
GROUP BY %Q GROUP BY %Q
@ -177,7 +180,7 @@ final class MultimeterSampleController extends MultimeterController {
MultimeterEvent::formatResourceCost( MultimeterEvent::formatResourceCost(
$viewer, $viewer,
$row['eventType'], $row['eventType'],
$row['totalCost'] / $row['N']), $row['averageCost']),
MultimeterEvent::formatResourceCost( MultimeterEvent::formatResourceCost(
$viewer, $viewer,
$row['eventType'], $row['eventType'],