1 | "use strict";
|
2 | var executer_1 = require("../executer");
|
3 | exports.DEFAULT_CONFIG = {
|
4 | reporters: [],
|
5 | reportDirectory: './reports/',
|
6 | };
|
7 | var waitTimeInner = function (timeInMs) {
|
8 | return {
|
9 | timeToWait: timeInMs
|
10 | };
|
11 | };
|
12 | var runInstancesInner = function (count, parallel) {
|
13 | if (parallel === void 0) { parallel = false; }
|
14 | return {
|
15 | parallel: parallel,
|
16 | totalCount: count
|
17 | };
|
18 | };
|
19 | var ExecutionInstance = (function () {
|
20 | function ExecutionInstance() {
|
21 | this.arr = [];
|
22 | }
|
23 | ExecutionInstance.prototype.getArr = function () {
|
24 | return this.arr;
|
25 | };
|
26 | ExecutionInstance.prototype.asString = function () {
|
27 | var actionsArr = [];
|
28 | this.arr.forEach(function (item) {
|
29 | if (item.totalCount) {
|
30 | actionsArr.push("I(" + item.totalCount + ")");
|
31 | }
|
32 | else if (item.timeToWait) {
|
33 | actionsArr.push("W(" + item.timeToWait + "ms)");
|
34 | }
|
35 | });
|
36 | return actionsArr.join(', ');
|
37 | };
|
38 | ExecutionInstance.prototype.waitTime = function (time) {
|
39 | this.arr.push(waitTimeInner(time));
|
40 | return this;
|
41 | };
|
42 | ExecutionInstance.prototype.runInstances = function (count, parallel) {
|
43 | if (parallel === void 0) { parallel = false; }
|
44 | this.arr.push(runInstancesInner(count, parallel));
|
45 | return this;
|
46 | };
|
47 | return ExecutionInstance;
|
48 | }());
|
49 | exports.ExecutionInstance = ExecutionInstance;
|
50 | exports.waitTime = function (time) {
|
51 | var ins = new ExecutionInstance();
|
52 | return ins.waitTime(time);
|
53 | };
|
54 | exports.runInstances = function (count, parallel) {
|
55 | if (parallel === void 0) { parallel = false; }
|
56 | var ins = new ExecutionInstance();
|
57 | return ins.runInstances(count, parallel);
|
58 | };
|
59 | exports.StressTest = function (options) {
|
60 | if (options === void 0) { options = { instances: [exports.runInstances(1)] }; }
|
61 | return function (target) {
|
62 | target.$$config = options;
|
63 | target.$$configFile = global['$$configFile'];
|
64 | executer_1.addToTestSuite(target);
|
65 | };
|
66 | };
|
67 |
|
\ | No newline at end of file |