Skip to content

Commit

Permalink
also draw the rcapacity
Browse files Browse the repository at this point in the history
  • Loading branch information
mirabilos committed Nov 9, 2023
1 parent b8ddceb commit 95fde4e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
10 changes: 6 additions & 4 deletions acquire/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ BEGIN
SELECT ts - d, qdelay * 1000, (qdelay - vqnb) * 1000, owd * 1000
FROM p, o
ORDER BY ts;
CREATE VIEW fbandwidth (dts, load, capacity, pktsizebytes) AS
CREATE VIEW fbandwidth (dts, load, rcapacity, vcapacity, pktsizebytes) AS
WITH
prefiltered AS (
SELECT ts, len FROM p
WHERE NOT p.isdrop
),
calculated AS (
SELECT ts, len AS pktsizebytes, vcap as bwlim,
SELECT ts, len AS pktsizebytes, vcap, rcap,
-- https://dba.stackexchange.com/a/105828/65843
count(vcap) OVER wts AS ct,
-- https://stackoverflow.com/a/77051480/2171120
Expand All @@ -115,12 +115,14 @@ BEGIN
),
filled AS (
SELECT ts, pktsizebytes, bps,
min(bwlim) OVER (PARTITION BY ct) AS bw
min(vcap) OVER (PARTITION BY ct) AS vbw,
min(rcap) OVER (PARTITION BY ct) AS rbw
FROM calculated
)
SELECT ts - d AS dts,
(TRUNC(bps) / 1000000)::NUMERIC(10,6) AS load,
(TRUNC(bw) / 1000000)::NUMERIC(10,6) AS capacity,
(TRUNC(rbw) / 1000000)::NUMERIC(10,6) AS rcapacity,
(TRUNC(vbw) / 1000000)::NUMERIC(10,6) AS vcapacity,
pktsizebytes
FROM filled, o ORDER BY ts;
RETURN sid;
Expand Down
32 changes: 23 additions & 9 deletions consume/diagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ usefulJS.deferDOM(function onDOMReady() {
var oldFormatter = Dygraph._require('dygraphs/src/plugins/legend.js').defaultFormatter;
var newFormatter = function newFormatter(data) {
if (typeof(data.x) !== 'undefined') {
data.series[2].isVisible = true;
data.series[2].y = data.dygraph.getValue(data.i, 3);
if (data.series[2].y !== null)
data.series[2].yHTML = data.series[2].y + 'b';
data.series[3].isVisible = true;
data.series[3].y = data.dygraph.getValue(data.i, 4);
if (data.series[3].y !== null)
data.series[3].yHTML = data.series[3].y + 'b';
}
return (oldFormatter(data));
};
g.gBW = new Dygraph(document.getElementById('divBandwidth'),
/* initial dummy data */ [[0,0,0,null],[1,1,1,null]], {
/* initial dummy data */ [[0,0,0,0,null],[1,1,1,1,null]], {
"axes": {
"x": {
"valueFormatter": function (x) {
Expand All @@ -159,11 +159,25 @@ usefulJS.deferDOM(function onDOMReady() {
"digitsAfterDecimal": 6
}
},
"series": {
"load": {
"color": "#009DE0"
},
"rcapacity": {
"color": "#E6ADEC"
},
"vcapacity": {
"color": "#E20074"
},
"pktsz": {
"color": "#E2001A"
}
},
"xlabel": "s",
"xLabelHeight": 0,
"ylabel": "Mbit/s",
"labels": ["time", "load", "capacity", "pktsz"],
"visibility": [true, true, false],
"labels": ["time", "load", "rcapacity", "vcapacity", "pktsz"],
"visibility": [true, true, true, false],
"connectSeparatedPoints": true,
"legendFormatter": newFormatter,
"underlayCallback": function (ctx, area, dy) {
Expand All @@ -185,10 +199,10 @@ usefulJS.deferDOM(function onDOMReady() {
var cx = canvasx(point);
if (cx < 0)
continue;
var len = dy.getValue(point.idx, 3);
var len = dy.getValue(point.idx, 4);
if (len === null)
continue;
var rate = dy.getValue(point.idx, 2);
var rate = dy.getValue(point.idx, 3);
var w = len * pps / rate;
if (w < 3)
return;
Expand Down

0 comments on commit 95fde4e

Please sign in to comment.