Skip to content

Commit ec63e32

Browse files
abobadalecurtis
authored andcommitted
Update encode/decode and queue depth statistics
1 parent 4c1070b commit ec63e32

File tree

1 file changed

+49
-17
lines changed

1 file changed

+49
-17
lines changed

samples/encode-decode-worker/js/stream_worker.js

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,43 @@ function enc_report() {
5151
enc_aggregate.all.sort();
5252
const len = enc_aggregate.all.length;
5353
const half = len >> 1;
54+
const f = (len + 1) >> 2;
55+
const t = (3 * (len + 1)) >> 2;
56+
const alpha1 = (len + 1)/4 - Math.trunc((len + 1)/4);
57+
const alpha3 = (3 * (len + 1)/4) - Math.trunc(3 * (len + 1)/4);
58+
const fquart = enc_aggregate.all[f] + alpha1 * (enc_aggregate.all[f + 1] - enc_aggregate.all[f]);
59+
const tquart = enc_aggregate.all[t] + alpha3 * (enc_aggregate.all[t + 1] - enc_aggregate.all[t]);
5460
const median = len % 2 === 1 ? enc_aggregate.all[len >> 1] : (enc_aggregate.all[half - 1] + enc_aggregate.all[half]) / 2;
5561
return {
5662
count: len,
5763
min: enc_aggregate.min,
58-
max: enc_aggregate.max,
64+
fquart: fquart,
5965
avg: enc_aggregate.sum / len,
60-
median,
66+
median: median,
67+
tquart: tquart,
68+
max: enc_aggregate.max,
6169
};
6270
}
6371

6472
function encqueue_report() {
6573
encqueue_aggregate.all.sort();
6674
const len = encqueue_aggregate.all.length;
6775
const half = len >> 1;
76+
const f = (len + 1) >> 2;
77+
const t = (3 * (len + 1)) >> 2;
78+
const alpha1 = (len + 1)/4 - Math.trunc((len + 1)/4);
79+
const alpha3 = (3 * (len + 1)/4) - Math.trunc(3 * (len + 1)/4);
80+
const fquart = encqueue_aggregate.all[f] + alpha1 * (encqueue_aggregate.all[f + 1] - encqueue_aggregate.all[f]);
81+
const tquart = encqueue_aggregate.all[t] + alpha3 * (encqueue_aggregate.all[t + 1] - encqueue_aggregate.all[t]);
6882
const median = len % 2 === 1 ? encqueue_aggregate.all[len >> 1] : (encqueue_aggregate.all[half - 1] + encqueue_aggregate.all[half]) / 2;
6983
return {
7084
count: len,
7185
min: encqueue_aggregate.min,
72-
max: encqueue_aggregate.max,
86+
fquart: fquart,
7387
avg: encqueue_aggregate.sum / len,
74-
median,
88+
median: median,
89+
tquart: tquart,
90+
max: encqueue_aggregate.max,
7591
};
7692
}
7793

@@ -82,38 +98,54 @@ function dec_update(duration) {
8298
dec_aggregate.sum += duration;
8399
}
84100

101+
function decqueue_update(duration) {
102+
decqueue_aggregate.all.push(duration);
103+
decqueue_aggregate.min = Math.min(decqueue_aggregate.min, duration);
104+
decqueue_aggregate.max = Math.max(decqueue_aggregate.max, duration);
105+
decqueue_aggregate.sum += duration;
106+
}
107+
85108
function dec_report() {
86109
dec_aggregate.all.sort();
87-
const len = dec_aggregate.all.length;
110+
const len = dec_aggregate.all.length;
88111
const half = len >> 1;
112+
const f = (len + 1) >> 2;
113+
const t = (3 * (len + 1)) >> 2;
114+
const alpha1 = (len + 1)/4 - Math.trunc((len + 1)/4);
115+
const alpha3 = (3 * (len + 1)/4) - Math.trunc(3 * (len + 1)/4);
116+
const fquart = dec_aggregate.all[f] + alpha1 * (dec_aggregate.all[f + 1] - dec_aggregate.all[f]);
117+
const tquart = dec_aggregate.all[t] + alpha3 * (dec_aggregate.all[t + 1] - dec_aggregate.all[t]);
89118
const median = len % 2 === 1 ? dec_aggregate.all[len >> 1] : (dec_aggregate.all[half - 1] + dec_aggregate.all[half]) / 2;
90119
return {
91120
count: len,
92121
min: dec_aggregate.min,
93-
max: dec_aggregate.max,
122+
fquart: fquart,
94123
avg: dec_aggregate.sum / len,
95-
median,
124+
median: median,
125+
tquart: tquart,
126+
max: dec_aggregate.max,
96127
};
97128
}
98129

99-
function decqueue_update(duration) {
100-
decqueue_aggregate.all.push(duration);
101-
decqueue_aggregate.min = Math.min(decqueue_aggregate.min, duration);
102-
decqueue_aggregate.max = Math.max(decqueue_aggregate.max, duration);
103-
decqueue_aggregate.sum += duration;
104-
}
105-
106130
function decqueue_report() {
107131
decqueue_aggregate.all.sort();
108-
const len = decqueue_aggregate.all.length;
132+
const len = decqueue_aggregate.all.length;
109133
const half = len >> 1;
134+
const f = (len + 1) >> 2;
135+
const t = (3 * (len + 1)) >> 2;
136+
const alpha1 = (len + 1)/4 - Math.trunc((len + 1)/4);
137+
const alpha3 = (3 * (len + 1)/4) - Math.trunc(3 * (len + 1)/4);
138+
const fquart = decqueue_aggregate.all[f] + alpha1 * (decqueue_aggregate.all[f + 1] - decqueue_aggregate.all[f]);
139+
const tquart = decqueue_aggregate.all[t] + alpha3 * (decqueue_aggregate.all[t + 1] - decqueue_aggregate.all[t]);
110140
const median = len % 2 === 1 ? decqueue_aggregate.all[len >> 1] : (decqueue_aggregate.all[half - 1] + decqueue_aggregate.all[half]) / 2;
111141
return {
112142
count: len,
113143
min: decqueue_aggregate.min,
114-
max: decqueue_aggregate.max,
144+
fquart: fquart,
115145
avg: decqueue_aggregate.sum / len,
116-
median,
146+
median: median,
147+
tquart: tquart,
148+
max: decqueue_aggregate.max,
117149
};
118150
}
119151

0 commit comments

Comments
 (0)