1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
13 | if (k2 === undefined) k2 = k;
|
14 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
15 | }) : (function(o, m, k, k2) {
|
16 | if (k2 === undefined) k2 = k;
|
17 | o[k2] = m[k];
|
18 | }));
|
19 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
20 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
21 | }) : function(o, v) {
|
22 | o["default"] = v;
|
23 | });
|
24 | var __importStar = (this && this.__importStar) || function (mod) {
|
25 | if (mod && mod.__esModule) return mod;
|
26 | var result = {};
|
27 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
28 | __setModuleDefault(result, mod);
|
29 | return result;
|
30 | };
|
31 | Object.defineProperty(exports, "__esModule", { value: true });
|
32 | exports.legacyJsonOutput = exports.jsonOutput = void 0;
|
33 | const systeminformation = __importStar(require("systeminformation"));
|
34 | const measure_1 = require("./measure");
|
35 | function jsonOutput(results) {
|
36 | const benchmarks = [];
|
37 | for (const result of results) {
|
38 | const differences = [];
|
39 | for (const difference of result.differences) {
|
40 | if (difference === null) {
|
41 | differences.push(null);
|
42 | }
|
43 | else {
|
44 | differences.push({
|
45 | absolute: {
|
46 | low: difference.absolute.low,
|
47 | high: difference.absolute.high,
|
48 | },
|
49 | percentChange: {
|
50 | low: difference.relative.low * 100,
|
51 | high: difference.relative.high * 100,
|
52 | },
|
53 | });
|
54 | }
|
55 | }
|
56 | benchmarks.push({
|
57 | name: result.result.name,
|
58 | bytesSent: result.result.bytesSent,
|
59 | version: result.result.version ? result.result.version : undefined,
|
60 | measurement: Object.assign({ name: measure_1.measurementName(result.result.measurement) }, result.result.measurement),
|
61 | browser: Object.assign(Object.assign({}, result.result.browser), { userAgent: result.result.userAgent }),
|
62 | mean: {
|
63 | low: result.stats.meanCI.low,
|
64 | high: result.stats.meanCI.high,
|
65 | },
|
66 | differences,
|
67 | samples: result.result.millis,
|
68 | });
|
69 | }
|
70 | return { benchmarks };
|
71 | }
|
72 | exports.jsonOutput = jsonOutput;
|
73 |
|
74 | async function legacyJsonOutput(results) {
|
75 |
|
76 | const battery = await systeminformation.battery();
|
77 | const cpu = await systeminformation.cpu();
|
78 | const currentLoad = await systeminformation.currentLoad();
|
79 | const memory = await systeminformation.mem();
|
80 | return {
|
81 | benchmarks: results,
|
82 | datetime: new Date().toISOString(),
|
83 | system: {
|
84 | cpu: {
|
85 | manufacturer: cpu.manufacturer,
|
86 | model: cpu.model,
|
87 | family: cpu.family,
|
88 | speed: cpu.speed,
|
89 | cores: cpu.cores,
|
90 | },
|
91 | load: {
|
92 | average: currentLoad.avgload,
|
93 | current: currentLoad.currentload,
|
94 | },
|
95 | battery: {
|
96 | hasBattery: battery.hasbattery,
|
97 | connected: battery.acconnected,
|
98 | },
|
99 | memory: {
|
100 | total: memory.total,
|
101 | free: memory.free,
|
102 | used: memory.used,
|
103 | active: memory.active,
|
104 | available: memory.available,
|
105 | },
|
106 | },
|
107 | };
|
108 | }
|
109 | exports.legacyJsonOutput = legacyJsonOutput;
|
110 |
|
\ | No newline at end of file |