@jsenv/test 3.0.22 → 3.0.24

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.
@@ -839,7 +839,7 @@ const createUnicode = ({ supported, ANSI }) => {
839
839
  };
840
840
 
841
841
  const UNICODE = createUnicode({
842
- supported: isUnicodeSupported(),
842
+ supported: isUnicodeSupported() || process.env.FORCE_UNICODE === "1",
843
843
  ANSI,
844
844
  });
845
845
 
@@ -3081,7 +3081,6 @@ const startMeasuringTotalCpuUsage = () => {
3081
3081
  system: 0,
3082
3082
  user: 0,
3083
3083
  };
3084
-
3085
3084
  const thisProcess = {
3086
3085
  active: 0,
3087
3086
  system: 0,
@@ -3101,7 +3100,7 @@ const startMeasuringTotalCpuUsage = () => {
3101
3100
  let cpuArray = cpus();
3102
3101
  const ms = Date.now();
3103
3102
  const ellapsedMs = ms - previousMs;
3104
- const cpuUsagesSample = [];
3103
+ const cpuUsageSampleArray = [];
3105
3104
  let overallSystemMs = 0;
3106
3105
  let overallUserMs = 0;
3107
3106
  let overallInactiveMs = 0;
@@ -3121,7 +3120,7 @@ const startMeasuringTotalCpuUsage = () => {
3121
3120
  system: systemMs / ellapsedMs,
3122
3121
  user: userMs / ellapsedMs,
3123
3122
  };
3124
- cpuUsagesSample.push(cpuUsageSample);
3123
+ cpuUsageSampleArray.push(cpuUsageSample);
3125
3124
 
3126
3125
  overallSystemMs += systemMs;
3127
3126
  overallUserMs += userMs;
@@ -3138,10 +3137,6 @@ const startMeasuringTotalCpuUsage = () => {
3138
3137
  };
3139
3138
  previousCpuArray = cpuArray;
3140
3139
  previousMs = ms;
3141
- samples.push({
3142
- cpuUsagesSample,
3143
- overallUsageSample,
3144
- });
3145
3140
 
3146
3141
  const processCpuUsage = cpuUsage();
3147
3142
  const thisProcessSystemMs = Math.round(
@@ -3151,53 +3146,83 @@ const startMeasuringTotalCpuUsage = () => {
3151
3146
  (processCpuUsage.user - previousCpuUsage.user) / 1000,
3152
3147
  );
3153
3148
  previousCpuUsage = processCpuUsage;
3154
- const thisProcessActiveMs = thisProcessSystemMs + thisProcessUserMs;
3155
- thisProcess.active = thisProcessActiveMs / overallMsEllapsed;
3156
- thisProcess.system = thisProcessSystemMs / overallMsEllapsed;
3157
- thisProcess.user = thisProcessUserMs / overallMsEllapsed;
3158
3149
 
3150
+ const thisProcessActiveMs = thisProcessSystemMs + thisProcessUserMs;
3151
+ const thisProcessInactiveMs = overallMsEllapsed - thisProcessActiveMs;
3152
+ const thisProcessSample = {
3153
+ inactive: thisProcessInactiveMs / overallMsEllapsed,
3154
+ active: thisProcessActiveMs / overallMsEllapsed,
3155
+ system: thisProcessSystemMs / overallMsEllapsed,
3156
+ user: thisProcessUserMs / overallMsEllapsed,
3157
+ };
3158
+ samples.push({
3159
+ cpuUsageSampleArray,
3160
+ overallUsageSample,
3161
+ thisProcessSample,
3162
+ });
3159
3163
  if (samples.length === 10) {
3160
- let index = 0;
3161
- for (const detail of details) {
3162
- let systemSum = 0;
3163
- let userSum = 0;
3164
- let inactiveSum = 0;
3165
- let activeSum = 0;
3164
+ {
3165
+ let index = 0;
3166
+ for (const detail of details) {
3167
+ let systemSum = 0;
3168
+ let userSum = 0;
3169
+ let inactiveSum = 0;
3170
+ let activeSum = 0;
3171
+ for (const sample of samples) {
3172
+ const { cpuUsageSampleArray } = sample;
3173
+ const cpuUsageSample = cpuUsageSampleArray[index];
3174
+ inactiveSum += cpuUsageSample.inactive;
3175
+ activeSum += cpuUsageSample.active;
3176
+ systemSum += cpuUsageSample.system;
3177
+ userSum += cpuUsageSample.user;
3178
+ }
3179
+ Object.assign(detail, {
3180
+ inactive: inactiveSum / samples.length,
3181
+ active: activeSum / samples.length,
3182
+ system: systemSum / samples.length,
3183
+ user: userSum / samples.length,
3184
+ });
3185
+ index++;
3186
+ }
3187
+ }
3188
+ {
3189
+ let overallSystemSum = 0;
3190
+ let overallUserSum = 0;
3191
+ let overallInactiveSum = 0;
3192
+ let overallActiveSum = 0;
3166
3193
  for (const sample of samples) {
3167
- const { cpuUsagesSample } = sample;
3168
- const cpuUsageSample = cpuUsagesSample[index];
3169
- inactiveSum += cpuUsageSample.inactive;
3170
- activeSum += cpuUsageSample.active;
3171
- systemSum += cpuUsageSample.system;
3172
- userSum += cpuUsageSample.user;
3194
+ const { overallUsageSample } = sample;
3195
+ overallSystemSum += overallUsageSample.system;
3196
+ overallUserSum += overallUsageSample.user;
3197
+ overallInactiveSum += overallUsageSample.inactive;
3198
+ overallActiveSum += overallUsageSample.active;
3173
3199
  }
3174
- Object.assign(detail, {
3175
- inactive: inactiveSum / samples.length,
3176
- active: activeSum / samples.length,
3177
- system: systemSum / samples.length,
3178
- user: userSum / samples.length,
3200
+ Object.assign(overall, {
3201
+ inactive: overallInactiveSum / samples.length,
3202
+ active: overallActiveSum / samples.length,
3203
+ system: overallSystemSum / samples.length,
3204
+ user: overallUserSum / samples.length,
3179
3205
  });
3180
- index++;
3181
3206
  }
3182
-
3183
- let overallSystemSum = 0;
3184
- let overallUserSum = 0;
3185
- let overallInactiveSum = 0;
3186
- let overallActiveSum = 0;
3187
- for (const sample of samples) {
3188
- const { overallUsageSample } = sample;
3189
- overallSystemSum += overallUsageSample.system;
3190
- overallUserSum += overallUsageSample.user;
3191
- overallInactiveSum += overallUsageSample.inactive;
3192
- overallActiveSum += overallUsageSample.active;
3207
+ {
3208
+ let thisProcessSystemSum = 0;
3209
+ let thisProcessUserSum = 0;
3210
+ let thisProcessInactiveSum = 0;
3211
+ let thisProcessActiveSum = 0;
3212
+ for (const sample of samples) {
3213
+ const { thisProcessSample } = sample;
3214
+ thisProcessSystemSum += thisProcessSample.system;
3215
+ thisProcessUserSum += thisProcessSample.user;
3216
+ thisProcessInactiveSum += thisProcessSample.inactive;
3217
+ thisProcessActiveSum += thisProcessSample.active;
3218
+ }
3219
+ Object.assign(thisProcess, {
3220
+ inactive: thisProcessInactiveSum / samples.length,
3221
+ active: thisProcessActiveSum / samples.length,
3222
+ system: thisProcessSystemSum / samples.length,
3223
+ user: thisProcessUserSum / samples.length,
3224
+ });
3193
3225
  }
3194
- Object.assign(overall, {
3195
- inactive: overallInactiveSum / samples.length,
3196
- active: overallActiveSum / samples.length,
3197
- system: overallSystemSum / samples.length,
3198
- user: overallUserSum / samples.length,
3199
- });
3200
- // console.log(formatUsage(globalUsageInfo));
3201
3226
  samples.length = 0;
3202
3227
  }
3203
3228
  }, 15);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/test",
3
- "version": "3.0.22",
3
+ "version": "3.0.24",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,13 +38,13 @@
38
38
  "dependencies": {
39
39
  "@c88/v8-coverage": "0.1.1",
40
40
  "@jsenv/abort": "4.3.0",
41
- "@jsenv/ast": "6.0.6",
42
- "@jsenv/filesystem": "4.6.8",
43
- "@jsenv/github-check-run": "0.1.13",
44
- "@jsenv/humanize": "1.1.2",
45
- "@jsenv/plugin-supervisor": "1.4.9",
41
+ "@jsenv/ast": "6.0.7",
42
+ "@jsenv/filesystem": "4.6.9",
43
+ "@jsenv/github-check-run": "0.1.14",
44
+ "@jsenv/humanize": "1.1.3",
45
+ "@jsenv/plugin-supervisor": "1.4.10",
46
46
  "@jsenv/url-meta": "8.4.0",
47
- "@jsenv/urls": "2.2.6",
47
+ "@jsenv/urls": "2.2.7",
48
48
  "@jsenv/utils": "2.1.1",
49
49
  "istanbul-lib-coverage": "3.2.2",
50
50
  "istanbul-lib-instrument": "6.0.3",
@@ -14,7 +14,6 @@ export const startMeasuringTotalCpuUsage = () => {
14
14
  system: 0,
15
15
  user: 0,
16
16
  };
17
-
18
17
  const thisProcess = {
19
18
  active: 0,
20
19
  system: 0,
@@ -34,7 +33,7 @@ export const startMeasuringTotalCpuUsage = () => {
34
33
  let cpuArray = cpus();
35
34
  const ms = Date.now();
36
35
  const ellapsedMs = ms - previousMs;
37
- const cpuUsagesSample = [];
36
+ const cpuUsageSampleArray = [];
38
37
  let overallSystemMs = 0;
39
38
  let overallUserMs = 0;
40
39
  let overallInactiveMs = 0;
@@ -54,7 +53,7 @@ export const startMeasuringTotalCpuUsage = () => {
54
53
  system: systemMs / ellapsedMs,
55
54
  user: userMs / ellapsedMs,
56
55
  };
57
- cpuUsagesSample.push(cpuUsageSample);
56
+ cpuUsageSampleArray.push(cpuUsageSample);
58
57
 
59
58
  overallSystemMs += systemMs;
60
59
  overallUserMs += userMs;
@@ -71,10 +70,6 @@ export const startMeasuringTotalCpuUsage = () => {
71
70
  };
72
71
  previousCpuArray = cpuArray;
73
72
  previousMs = ms;
74
- samples.push({
75
- cpuUsagesSample,
76
- overallUsageSample,
77
- });
78
73
 
79
74
  const processCpuUsage = cpuUsage();
80
75
  const thisProcessSystemMs = Math.round(
@@ -84,53 +79,83 @@ export const startMeasuringTotalCpuUsage = () => {
84
79
  (processCpuUsage.user - previousCpuUsage.user) / 1000,
85
80
  );
86
81
  previousCpuUsage = processCpuUsage;
87
- const thisProcessActiveMs = thisProcessSystemMs + thisProcessUserMs;
88
- thisProcess.active = thisProcessActiveMs / overallMsEllapsed;
89
- thisProcess.system = thisProcessSystemMs / overallMsEllapsed;
90
- thisProcess.user = thisProcessUserMs / overallMsEllapsed;
91
82
 
83
+ const thisProcessActiveMs = thisProcessSystemMs + thisProcessUserMs;
84
+ const thisProcessInactiveMs = overallMsEllapsed - thisProcessActiveMs;
85
+ const thisProcessSample = {
86
+ inactive: thisProcessInactiveMs / overallMsEllapsed,
87
+ active: thisProcessActiveMs / overallMsEllapsed,
88
+ system: thisProcessSystemMs / overallMsEllapsed,
89
+ user: thisProcessUserMs / overallMsEllapsed,
90
+ };
91
+ samples.push({
92
+ cpuUsageSampleArray,
93
+ overallUsageSample,
94
+ thisProcessSample,
95
+ });
92
96
  if (samples.length === 10) {
93
- let index = 0;
94
- for (const detail of details) {
95
- let systemSum = 0;
96
- let userSum = 0;
97
- let inactiveSum = 0;
98
- let activeSum = 0;
97
+ per_cpu: {
98
+ let index = 0;
99
+ for (const detail of details) {
100
+ let systemSum = 0;
101
+ let userSum = 0;
102
+ let inactiveSum = 0;
103
+ let activeSum = 0;
104
+ for (const sample of samples) {
105
+ const { cpuUsageSampleArray } = sample;
106
+ const cpuUsageSample = cpuUsageSampleArray[index];
107
+ inactiveSum += cpuUsageSample.inactive;
108
+ activeSum += cpuUsageSample.active;
109
+ systemSum += cpuUsageSample.system;
110
+ userSum += cpuUsageSample.user;
111
+ }
112
+ Object.assign(detail, {
113
+ inactive: inactiveSum / samples.length,
114
+ active: activeSum / samples.length,
115
+ system: systemSum / samples.length,
116
+ user: userSum / samples.length,
117
+ });
118
+ index++;
119
+ }
120
+ }
121
+ all: {
122
+ let overallSystemSum = 0;
123
+ let overallUserSum = 0;
124
+ let overallInactiveSum = 0;
125
+ let overallActiveSum = 0;
99
126
  for (const sample of samples) {
100
- const { cpuUsagesSample } = sample;
101
- const cpuUsageSample = cpuUsagesSample[index];
102
- inactiveSum += cpuUsageSample.inactive;
103
- activeSum += cpuUsageSample.active;
104
- systemSum += cpuUsageSample.system;
105
- userSum += cpuUsageSample.user;
127
+ const { overallUsageSample } = sample;
128
+ overallSystemSum += overallUsageSample.system;
129
+ overallUserSum += overallUsageSample.user;
130
+ overallInactiveSum += overallUsageSample.inactive;
131
+ overallActiveSum += overallUsageSample.active;
106
132
  }
107
- Object.assign(detail, {
108
- inactive: inactiveSum / samples.length,
109
- active: activeSum / samples.length,
110
- system: systemSum / samples.length,
111
- user: userSum / samples.length,
133
+ Object.assign(overall, {
134
+ inactive: overallInactiveSum / samples.length,
135
+ active: overallActiveSum / samples.length,
136
+ system: overallSystemSum / samples.length,
137
+ user: overallUserSum / samples.length,
112
138
  });
113
- index++;
114
139
  }
115
-
116
- let overallSystemSum = 0;
117
- let overallUserSum = 0;
118
- let overallInactiveSum = 0;
119
- let overallActiveSum = 0;
120
- for (const sample of samples) {
121
- const { overallUsageSample } = sample;
122
- overallSystemSum += overallUsageSample.system;
123
- overallUserSum += overallUsageSample.user;
124
- overallInactiveSum += overallUsageSample.inactive;
125
- overallActiveSum += overallUsageSample.active;
140
+ this_process: {
141
+ let thisProcessSystemSum = 0;
142
+ let thisProcessUserSum = 0;
143
+ let thisProcessInactiveSum = 0;
144
+ let thisProcessActiveSum = 0;
145
+ for (const sample of samples) {
146
+ const { thisProcessSample } = sample;
147
+ thisProcessSystemSum += thisProcessSample.system;
148
+ thisProcessUserSum += thisProcessSample.user;
149
+ thisProcessInactiveSum += thisProcessSample.inactive;
150
+ thisProcessActiveSum += thisProcessSample.active;
151
+ }
152
+ Object.assign(thisProcess, {
153
+ inactive: thisProcessInactiveSum / samples.length,
154
+ active: thisProcessActiveSum / samples.length,
155
+ system: thisProcessSystemSum / samples.length,
156
+ user: thisProcessUserSum / samples.length,
157
+ });
126
158
  }
127
- Object.assign(overall, {
128
- inactive: overallInactiveSum / samples.length,
129
- active: overallActiveSum / samples.length,
130
- system: overallSystemSum / samples.length,
131
- user: overallUserSum / samples.length,
132
- });
133
- // console.log(formatUsage(globalUsageInfo));
134
159
  samples.length = 0;
135
160
  }
136
161
  }, 15);
@@ -11,5 +11,7 @@ setInterval(() => {
11
11
 
12
12
  const totalCpuUsage = startMeasuringTotalCpuUsage();
13
13
  setInterval(() => {
14
- console.log(formatUsage(totalCpuUsage.overall));
14
+ console.log(`overall: ${formatUsage(totalCpuUsage.overall)}
15
+ this process: ${formatUsage(totalCpuUsage.thisProcess)}
16
+ `);
15
17
  }, 400);