@vpalmisano/webrtcperf 4.4.11 → 4.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/index.d.ts +1 -0
- package/build/src/index.js +1 -0
- package/build/src/index.js.map +1 -1
- package/build/src/plot.d.ts +13 -0
- package/build/src/plot.js +50 -0
- package/build/src/plot.js.map +1 -0
- package/build/src/scenarios.d.ts +3 -0
- package/build/src/scenarios.js +6 -2
- package/build/src/scenarios.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/index.ts +1 -0
- package/src/plot.ts +85 -0
- package/src/scenarios.ts +6 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpalmisano/webrtcperf",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.12",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/vpalmisano/webrtcperf.git"
|
|
@@ -130,7 +130,8 @@
|
|
|
130
130
|
},
|
|
131
131
|
"optionalDependencies": {
|
|
132
132
|
"chart.js": "^4.5.0",
|
|
133
|
-
"
|
|
133
|
+
"chartjs-chart-error-bars": "^4.4.4",
|
|
134
|
+
"skia-canvas": "^3.0.7",
|
|
134
135
|
"zeromq": "^6.5.0"
|
|
135
136
|
}
|
|
136
137
|
}
|
package/src/index.ts
CHANGED
package/src/plot.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { logger } from './utils'
|
|
2
|
+
|
|
3
|
+
const log = logger('webrtcperf:plot')
|
|
4
|
+
|
|
5
|
+
export type PlotData = {
|
|
6
|
+
x: (string | number)[]
|
|
7
|
+
y: number[]
|
|
8
|
+
label: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type PlotOptions = {
|
|
12
|
+
type?: string
|
|
13
|
+
title?: string
|
|
14
|
+
filePath?: string
|
|
15
|
+
min?: number
|
|
16
|
+
max?: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function plot(data: PlotData, options: PlotOptions) {
|
|
20
|
+
const {
|
|
21
|
+
CategoryScale,
|
|
22
|
+
Chart,
|
|
23
|
+
LinearScale,
|
|
24
|
+
LineController,
|
|
25
|
+
BarController,
|
|
26
|
+
LineElement,
|
|
27
|
+
BarElement,
|
|
28
|
+
PointElement,
|
|
29
|
+
Legend,
|
|
30
|
+
Title,
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
32
|
+
} = require('chart.js')
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
34
|
+
const ErrorBarsPlugin = require('chartjs-chart-error-bars')
|
|
35
|
+
Chart.register(
|
|
36
|
+
CategoryScale,
|
|
37
|
+
LineController,
|
|
38
|
+
LineElement,
|
|
39
|
+
BarController,
|
|
40
|
+
LinearScale,
|
|
41
|
+
BarElement,
|
|
42
|
+
PointElement,
|
|
43
|
+
Legend,
|
|
44
|
+
Title,
|
|
45
|
+
ErrorBarsPlugin,
|
|
46
|
+
)
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
48
|
+
const { Canvas } = require('skia-canvas')
|
|
49
|
+
|
|
50
|
+
log.debug('plot')
|
|
51
|
+
|
|
52
|
+
const canvas = new Canvas(1280, 720)
|
|
53
|
+
const chart = new Chart(canvas, {
|
|
54
|
+
type: options.type || 'line',
|
|
55
|
+
data: {
|
|
56
|
+
labels: data.x,
|
|
57
|
+
datasets: [
|
|
58
|
+
{
|
|
59
|
+
label: data.label,
|
|
60
|
+
data: data.y,
|
|
61
|
+
fill: false,
|
|
62
|
+
borderColor: 'rgb(0, 0, 0)',
|
|
63
|
+
borderWidth: 1,
|
|
64
|
+
pointRadius: 0,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
options: {
|
|
69
|
+
plugins: {
|
|
70
|
+
title: {
|
|
71
|
+
display: !!options.title,
|
|
72
|
+
text: options.title || '',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
scales: {
|
|
76
|
+
y: {
|
|
77
|
+
min: options.min,
|
|
78
|
+
max: options.max,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
})
|
|
83
|
+
await canvas.toFile(options.filePath || 'plot.png', { format: 'png', matte: 'white' })
|
|
84
|
+
chart.destroy()
|
|
85
|
+
}
|
package/src/scenarios.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { ThrottleConfig, ThrottleRule } from '@vpalmisano/throttler'
|
|
|
5
5
|
import { Config } from './config'
|
|
6
6
|
import { Auth, google } from 'googleapis'
|
|
7
7
|
import { logger } from './utils'
|
|
8
|
+
import { sprintf } from 'sprintf-js'
|
|
8
9
|
|
|
9
10
|
const log = logger('webrtcperf:scenarios')
|
|
10
11
|
|
|
@@ -154,21 +155,21 @@ export async function uploadStatsToGoogleSheet(stats: StatsSummary[], spreadshee
|
|
|
154
155
|
|
|
155
156
|
export type ThrottleDirection = 'up' | 'down' | 'bidi'
|
|
156
157
|
|
|
157
|
-
function formatBitrate(bitrate: number | undefined, prefix = ' ') {
|
|
158
|
+
export function formatBitrate(bitrate: number | undefined, prefix = ' ') {
|
|
158
159
|
if (bitrate === undefined) return ''
|
|
159
160
|
let suffix = 'Kbps'
|
|
160
|
-
if (bitrate >=
|
|
161
|
+
if (bitrate >= 1000) {
|
|
161
162
|
bitrate /= 1000
|
|
162
163
|
suffix = 'Mbps'
|
|
163
164
|
}
|
|
164
|
-
return `${prefix}${bitrate
|
|
165
|
+
return `${prefix}${sprintf('%5.4g', bitrate)}${suffix}`
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
function formatLoss(loss: number | undefined, prefix = ' ') {
|
|
168
|
+
export function formatLoss(loss: number | undefined, prefix = ' ') {
|
|
168
169
|
return loss !== undefined ? `${prefix}${loss.toFixed(0).padStart(2, ' ')}%` : ''
|
|
169
170
|
}
|
|
170
171
|
|
|
171
|
-
function formatDelay(delay: number | undefined, prefix = ' ') {
|
|
172
|
+
export function formatDelay(delay: number | undefined, prefix = ' ') {
|
|
172
173
|
return delay !== undefined ? `${prefix}${delay.toFixed(0).padStart(3, ' ')}ms` : ''
|
|
173
174
|
}
|
|
174
175
|
|