@vpalmisano/webrtcperf 4.4.7 → 4.4.9

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/src/utils.ts CHANGED
@@ -1284,23 +1284,30 @@ export async function aggregateStatsSummary({
1284
1284
  return { destination, scenario }
1285
1285
  },
1286
1286
  }) {
1287
- const stats = {} as Record<
1288
- string,
1289
- {
1290
- destination: string
1291
- scenario: string
1292
- videoRecvBitratePerPixel: FastStats
1293
- videoRecvFps: FastStats
1294
- videoSentFps: FastStats
1295
- }
1296
- >
1287
+ const stats = [] as {
1288
+ timestamp: number
1289
+ destination: string
1290
+ scenario: string
1291
+ videoRecvBitratePerPixel: FastStats
1292
+ videoRecvFps: FastStats
1293
+ videoSentFps: FastStats
1294
+ }[]
1297
1295
  const results = await fs.promises.readdir(dirPath)
1298
1296
  for (const test of results) {
1299
1297
  const filePath = path.join(dirPath, test, 'detailed-stats-summary.csv')
1300
1298
  if (!fs.existsSync(filePath)) continue
1299
+ const timestamp = fs.statSync(path.join(dirPath, test)).ctime.getTime()
1301
1300
  const data = await parseStatsFile(filePath)
1302
-
1303
- const aggregated = {} as Record<string, number>
1301
+ const { destination, scenario } = nameParser(test)
1302
+
1303
+ const aggregated = {
1304
+ timestamp,
1305
+ destination,
1306
+ scenario,
1307
+ videoRecvBitratePerPixel: new FastStats(),
1308
+ videoRecvFps: new FastStats(),
1309
+ videoSentFps: new FastStats(),
1310
+ }
1304
1311
  data.forEach(v => {
1305
1312
  const { participantName, trackId } = v as { participantName: string; trackId: string }
1306
1313
  const metrics = v as Record<string, number>
@@ -1308,35 +1315,16 @@ export async function aggregateStatsSummary({
1308
1315
  if (trackId?.endsWith('-v') && metrics.videoRecvFrames > 0) {
1309
1316
  const videoRecvBitratePerPixel =
1310
1317
  metrics.videoRecvBitrates / (metrics.videoRecvWidth * metrics.videoRecvHeight)
1311
- aggregated.videoRecvBitratePerPixel = Math.max(
1312
- aggregated.videoRecvBitratePerPixel || 0,
1313
- videoRecvBitratePerPixel,
1314
- )
1315
- aggregated.videoRecvFps = Math.max(aggregated.videoRecvFps || 0, metrics.videoRecvFps)
1318
+ if (!isNaN(videoRecvBitratePerPixel)) aggregated.videoRecvBitratePerPixel.push(videoRecvBitratePerPixel)
1319
+ if (!isNaN(metrics.videoRecvFps)) aggregated.videoRecvFps.push(metrics.videoRecvFps)
1316
1320
  }
1317
1321
  } else if (participantName === senderParticipantName) {
1318
1322
  if (trackId?.endsWith('-v') && metrics.videoSentFrames > 0) {
1319
- aggregated.videoSentFps = Math.max(aggregated.videoSentFps || 0, metrics.videoSentFps)
1323
+ if (!isNaN(metrics.videoSentFps)) aggregated.videoSentFps.push(metrics.videoSentFps)
1320
1324
  }
1321
1325
  }
1322
1326
  })
1323
- if (Object.keys(aggregated).length === 0) continue
1324
-
1325
- const { destination, scenario, ...args } = nameParser(test)
1326
- const key = `${destination}|${scenario}`
1327
- if (!stats[key]) {
1328
- stats[key] = {
1329
- destination,
1330
- scenario,
1331
- ...args,
1332
- videoRecvBitratePerPixel: new FastStats(),
1333
- videoRecvFps: new FastStats(),
1334
- videoSentFps: new FastStats(),
1335
- }
1336
- }
1337
- stats[key].videoRecvBitratePerPixel.push(aggregated.videoRecvBitratePerPixel)
1338
- stats[key].videoRecvFps.push(aggregated.videoRecvFps)
1339
- stats[key].videoSentFps.push(aggregated.videoSentFps)
1327
+ stats.push(aggregated)
1340
1328
  }
1341
- return Object.values(stats).sort((a, b) => a.scenario.localeCompare(b.scenario))
1329
+ return stats.sort((a, b) => a.timestamp - b.timestamp)
1342
1330
  }