You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2018/08/09 06:27:53 UTC
[GitHub] bwh12398 closed pull request #1535: 优化代码结构,减少不必要的计算,节省计算资源
bwh12398 closed pull request #1535: 优化代码结构,减少不必要的计算,节省计算资源
URL: https://github.com/apache/incubator-skywalking/pull/1535
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionSpanListener.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionSpanListener.java
index ea14849fb..e467d5244 100644
--- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionSpanListener.java
+++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionSpanListener.java
@@ -73,15 +73,16 @@ public void parseFirst(SpanDecorator spanDecorator, SegmentCoreInfo segmentCoreI
}
int getStep(int duration) {
- int countOfResponseTimeSteps = configService.getResponseTimeStep() * configService.getCountOfResponseTimeSteps();
int responseTimeStep = configService.getResponseTimeStep();
+ int countOfResponseTimeSteps = configService.getCountOfResponseTimeSteps();
+ int totalTimeOfResponseTimeSteps = configService.getTotalTimeOfResponseTimeSteps();
- if (duration > countOfResponseTimeSteps) {
- return countOfResponseTimeSteps / responseTimeStep;
+ if (duration > totalTimeOfResponseTimeSteps) {
+ return countOfResponseTimeSteps;
} else if (duration <= responseTimeStep) {
return 0;
} else {
- return (int)Math.ceil((double)duration / (double)responseTimeStep) - 1;
+ return (int) Math.ceil((double) duration / (double) responseTimeStep) - 1;
}
}
diff --git a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IResponseTimeDistributionConfigService.java b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IResponseTimeDistributionConfigService.java
index 7cec4c441..5a6d25e8c 100644
--- a/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IResponseTimeDistributionConfigService.java
+++ b/apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IResponseTimeDistributionConfigService.java
@@ -28,4 +28,12 @@
int getResponseTimeStep();
int getCountOfResponseTimeSteps();
+
+ /**
+ * Equals to getResponseTimeStep() * getCountOfResponseTimeSteps() ,just for economizes computing resources
+ *
+ * @return
+ */
+ int getTotalTimeOfResponseTimeSteps();
+
}
diff --git a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ResponseTimeDistributionConfigService.java b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ResponseTimeDistributionConfigService.java
index cc50be2d8..87ed2a2c3 100644
--- a/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ResponseTimeDistributionConfigService.java
+++ b/apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ResponseTimeDistributionConfigService.java
@@ -25,10 +25,12 @@
private final int responseTimeStep;
private final int countOfResponseTimeSteps;
+ private final int totalTimeOfResponseTimeSteps;
public ResponseTimeDistributionConfigService(int responseTimeStep, int countOfResponseTimeSteps) {
this.responseTimeStep = responseTimeStep;
this.countOfResponseTimeSteps = countOfResponseTimeSteps + 1;
+ this.totalTimeOfResponseTimeSteps = this.responseTimeStep * this.countOfResponseTimeSteps;
}
@Override public int getResponseTimeStep() {
@@ -38,4 +40,9 @@ public ResponseTimeDistributionConfigService(int responseTimeStep, int countOfRe
@Override public int getCountOfResponseTimeSteps() {
return countOfResponseTimeSteps;
}
+
+ @Override
+ public int getTotalTimeOfResponseTimeSteps() {
+ return totalTimeOfResponseTimeSteps;
+ }
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services