@loadmill/executer 0.1.52 → 0.1.53
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/package.json +3 -3
- package/src/asserter.ts +0 -137
- package/src/errors.ts +0 -10
- package/src/extraction-combiner.ts +0 -110
- package/src/failures.ts +0 -79
- package/src/message-creators.ts +0 -44
- package/src/mill-info.ts +0 -81
- package/src/mill-version.ts +0 -7
- package/src/post-script/ast-walker/index.ts +0 -160
- package/src/post-script/ast-walker/type-guard.ts +0 -73
- package/src/post-script/ast-walker/types.ts +0 -35
- package/src/post-script/console-log.ts +0 -24
- package/src/post-script/parser/acorn-js-parser.ts +0 -8
- package/src/post-script/parser/js-parser.ts +0 -22
- package/src/post-script/parser/parser.ts +0 -5
- package/src/post-script/post-script-executor.ts +0 -93
- package/src/post-script/virtual-machine/virtual-machine.ts +0 -15
- package/src/post-script/virtual-machine/vm2-virtual-machine.ts +0 -45
- package/src/report-types.ts +0 -127
- package/src/request-sequence-result.ts +0 -63
- package/src/request-stats.ts +0 -20
- package/src/res-keeper.ts +0 -53
- package/src/sampler.ts +0 -133
- package/src/sequence.ts +0 -1115
- package/src/single-runner.ts +0 -68
- package/src/test-run-event-emitter.ts +0 -25
- package/src/utils.ts +0 -8
- package/src/work.ts +0 -17
- package/src/ws.ts +0 -286
- package/test/post-script-console-log.spec.ts +0 -73
- package/test/post-script-executor.spec.ts +0 -685
- package/tsconfig.json +0 -9
package/src/sampler.ts
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import log from '@loadmill/universal/dist/log';
|
|
2
|
-
import * as mathUtils from '@loadmill/universal/dist/math-utils';
|
|
3
|
-
import * as promiseUtils from '@loadmill/universal/dist/promise-utils';
|
|
4
|
-
import { minimalRemainingDuration, reportDelay } from '@loadmill/core/dist/conf';
|
|
5
|
-
import { runSingleIteration } from './single-runner';
|
|
6
|
-
import { Failures, mergeFailures } from './failures';
|
|
7
|
-
import { PerRequestStats, setReqStats } from './request-stats';
|
|
8
|
-
import { Work } from './work';
|
|
9
|
-
import { messageCreators } from './message-creators';
|
|
10
|
-
import { DEFAULT_DURATION, DEFAULT_ITERATION_DELAY } from '@loadmill/core/dist/conf/defaults';
|
|
11
|
-
|
|
12
|
-
// 5 minutes:
|
|
13
|
-
const RES_KEEP_TIME = 5 * 60 * 1000;
|
|
14
|
-
|
|
15
|
-
export interface SamplerFaja {
|
|
16
|
-
cancelWork(finished: boolean);
|
|
17
|
-
send(obj: string);
|
|
18
|
-
reportIntervalId;
|
|
19
|
-
isStopped: boolean;
|
|
20
|
-
keeper;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class Sampler {
|
|
24
|
-
avgResTime = 0;
|
|
25
|
-
expired = false;
|
|
26
|
-
successfulHits = 0;
|
|
27
|
-
failedIterations = 0;
|
|
28
|
-
startedIterations = 0;
|
|
29
|
-
failures: Failures = {};
|
|
30
|
-
successfulIterations = 0;
|
|
31
|
-
requestStats: PerRequestStats = {};
|
|
32
|
-
|
|
33
|
-
constructor(private samplerMill: SamplerFaja, private work: Work) {}
|
|
34
|
-
|
|
35
|
-
startSampling = () => {
|
|
36
|
-
this.samplerMill.cancelWork(false);
|
|
37
|
-
|
|
38
|
-
promiseUtils.delay(this.work.duration || DEFAULT_DURATION).then(
|
|
39
|
-
() => {
|
|
40
|
-
if (!this.samplerMill.isStopped) {
|
|
41
|
-
log.debug('Time\'s up!');
|
|
42
|
-
this.expired = true;
|
|
43
|
-
this.sendReport();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const requests = this.work.requests;
|
|
49
|
-
const iterationDelay = this.work.iterationDelay || DEFAULT_ITERATION_DELAY;
|
|
50
|
-
|
|
51
|
-
const reportDelayy = reportDelay(iterationDelay, requests);
|
|
52
|
-
this.samplerMill.reportIntervalId = setInterval(
|
|
53
|
-
this.sendReport,
|
|
54
|
-
reportDelayy
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
this.samplerMill.isStopped = false;
|
|
58
|
-
this.runAll();
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
runAll = async () => {
|
|
62
|
-
while (!this.isDone()) {
|
|
63
|
-
++this.startedIterations;
|
|
64
|
-
log.trace('Executing iteration: ', this.startedIterations);
|
|
65
|
-
|
|
66
|
-
const res = await runSingleIteration(this.work);
|
|
67
|
-
this.samplerMill.keeper.keepIfNeeded(res, RES_KEEP_TIME);
|
|
68
|
-
|
|
69
|
-
const resFailures = res.failures;
|
|
70
|
-
|
|
71
|
-
if (!resFailures || Object.keys(resFailures).length === 0) {
|
|
72
|
-
++this.successfulIterations;
|
|
73
|
-
} else {
|
|
74
|
-
++this.failedIterations;
|
|
75
|
-
mergeFailures(this.failures, resFailures);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
this.avgResTime = mathUtils.calcAvg(
|
|
79
|
-
this.avgResTime,
|
|
80
|
-
this.successfulHits,
|
|
81
|
-
res.avgResTime,
|
|
82
|
-
res.successfulHits
|
|
83
|
-
);
|
|
84
|
-
this.successfulHits += res.successfulHits;
|
|
85
|
-
|
|
86
|
-
Object.keys(res.requestStats).forEach(index => {
|
|
87
|
-
setReqStats(this.requestStats, index, ...res.requestStats[index].resTimes);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (!this.isDone()) {
|
|
92
|
-
// We count only the delay of the requests that were NOT ATTEMPTED.
|
|
93
|
-
// Note that the first request delay is always ignored:
|
|
94
|
-
const skipCount = res.lastStartedIndex + 1;
|
|
95
|
-
await promiseUtils.delay(
|
|
96
|
-
minimalRemainingDuration(
|
|
97
|
-
this.work.iterationDelay || DEFAULT_ITERATION_DELAY,
|
|
98
|
-
this.work.requests,
|
|
99
|
-
skipCount
|
|
100
|
-
)
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (!this.samplerMill.isStopped) {
|
|
106
|
-
log.debug('Finished last iteration:', this.startedIterations);
|
|
107
|
-
this.sendReport();
|
|
108
|
-
this.samplerMill.cancelWork(true);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
isDone = () => {
|
|
113
|
-
return this.samplerMill.isStopped || this.expired || this.startedIterations >= this.work.iterations;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
sendReport = () => {
|
|
117
|
-
const report = {
|
|
118
|
-
failures: this.failures,
|
|
119
|
-
hits: this.successfulHits,
|
|
120
|
-
avgResTime: this.avgResTime,
|
|
121
|
-
requestStats: this.requestStats,
|
|
122
|
-
failedIterations: this.failedIterations,
|
|
123
|
-
successfulIterations: this.successfulIterations,
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
log.trace('Sending report:', report);
|
|
127
|
-
this.samplerMill.send(messageCreators.report(report));
|
|
128
|
-
|
|
129
|
-
this.failures = {};
|
|
130
|
-
this.requestStats = {};
|
|
131
|
-
this.successfulIterations = this.successfulHits = this.failedIterations = this.avgResTime = 0;
|
|
132
|
-
};
|
|
133
|
-
}
|