diff --git a/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue b/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue index a8291aba21..ef68f07466 100644 --- a/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue +++ b/frontend/src/business/components/performance/test/components/PerformancePressureConfig.vue @@ -364,6 +364,19 @@ export default { this.$set(this.threadGroups[i], "deleted", this.threadGroups[i].deleted || 'false'); }); } + for (let i = 0; i < this.threadGroups.length; i++) { + // 恢复成单位需要的值 + switch (this.threadGroups[i].unit) { + case 'M': + this.threadGroups[i].duration = this.threadGroups[i].duration / 60; + break; + case 'H': + this.threadGroups[i].duration = this.threadGroups[i].duration / 60 / 60; + break; + default: + break; + } + } this.calculateTotalChart(); } }); @@ -474,7 +487,20 @@ export default { let threadInc1 = Math.floor(tg.threadNumber / tg.step); let threadInc2 = Math.ceil(tg.threadNumber / tg.step); let inc2count = tg.threadNumber - tg.step * threadInc1; - for (let j = 0; j <= tg.duration; j++) { + + let times = 1; + switch (tg.unit) { + case 'M': + times *= 60; + break; + case 'H': + times *= 3600; + break; + default: + break; + } + let duration = tg.duration * times; + for (let j = 0; j <= duration; j++) { // x 轴 let xAxis = handler.options.xAxis.data; if (xAxis.indexOf(j) < 0) { @@ -487,10 +513,10 @@ export default { seriesData.data.push([0, 0]); } if (j >= tg.rampUpTime) { - xAxis.push(tg.duration); + xAxis.push(duration); seriesData.data.push([j, tg.threadNumber]); - seriesData.data.push([tg.duration, tg.threadNumber]); + seriesData.data.push([duration, tg.threadNumber]); break; } } else { @@ -506,8 +532,8 @@ export default { if (threadPeriod > tg.threadNumber) { threadPeriod = tg.threadNumber; // 预热结束 - xAxis.push(tg.duration); - seriesData.data.push([tg.duration, threadPeriod]); + xAxis.push(duration); + seriesData.data.push([duration, threadPeriod]); break; } } @@ -517,119 +543,6 @@ export default { handler.options.series.push(seriesData); } }, - calculateChart(threadGroup) { - let handler = this; - if (threadGroup) { - handler = threadGroup; - } - if (handler.duration < handler.rampUpTime) { - handler.rampUpTime = handler.duration; - } - if (handler.rampUpTime < handler.step) { - handler.step = handler.rampUpTime; - } - - handler.options = { - xAxis: { - type: 'category', - boundaryGap: false, - data: [] - }, - yAxis: { - type: 'value' - }, - tooltip: { - trigger: 'axis', - formatter: '{a}: {c0}', - axisPointer: { - lineStyle: { - color: '#57617B' - } - } - }, - series: [{ - name: 'User', - data: [], - type: 'line', - step: 'start', - smooth: false, - symbolSize: 5, - showSymbol: false, - lineStyle: { - normal: { - width: 1 - } - }, - areaStyle: { - normal: { - color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ - offset: 0, - color: 'rgba(137, 189, 27, 0.3)' - }, { - offset: 0.8, - color: 'rgba(137, 189, 27, 0)' - }], false), - shadowColor: 'rgba(0, 0, 0, 0.1)', - shadowBlur: 10 - } - }, - itemStyle: { - normal: { - color: 'rgb(137,189,27)', - borderColor: 'rgba(137,189,2,0.27)', - borderWidth: 12 - } - }, - }] - }; - let timePeriod = Math.floor(handler.rampUpTime / handler.step); - let timeInc = timePeriod; - - let threadPeriod = Math.floor(handler.threadNumber / handler.step); - let threadInc1 = Math.floor(handler.threadNumber / handler.step); - let threadInc2 = Math.ceil(handler.threadNumber / handler.step); - let inc2count = handler.threadNumber - handler.step * threadInc1; - for (let i = 0; i <= handler.duration; i++) { - // x 轴 - handler.options.xAxis.data.push(i); - - if (handler.tgType === 'ThreadGroup') { - handler.options.series[0].step = undefined; - - if (i === 0) { - handler.options.series[0].data.push([0, 0]); - } - if (i >= handler.rampUpTime) { - handler.options.xAxis.data.push(handler.duration); - - handler.options.series[0].data.push([i, handler.threadNumber]); - handler.options.series[0].data.push([handler.duration, handler.threadNumber]); - break; - } - } else { - handler.options.series[0].step = 'start'; - if (i > timePeriod) { - timePeriod += timeInc; - if (inc2count > 0) { - threadPeriod = threadPeriod + threadInc2; - inc2count--; - } else { - threadPeriod = threadPeriod + threadInc1; - } - if (threadPeriod > handler.threadNumber) { - threadPeriod = handler.threadNumber; - handler.options.xAxis.data.push(handler.duration); - handler.options.series[0].data.push([handler.duration, handler.threadNumber]); - break; - } - handler.options.series[0].data.push([i, threadPeriod]); - } else { - handler.options.series[0].data.push([i, threadPeriod]); - } - } - } - this.calculateTotalChart(); - }, validConfig() { if (!this.resourcePool) { this.$warning(this.$t('load_test.resource_pool_is_null')); @@ -683,6 +596,7 @@ export default { this.rampUpTimeVisible = false; this.$nextTick(() => { this.rampUpTimeVisible = true; + this.calculateTotalChart(); }); }, getUnitLabel(tg) {