Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
6db0d08f
S
SkyWalking
项目概览
山不在高_有仙则灵
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
12
Star
0
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6db0d08f
编写于
8月 09, 2018
作者:
鲍
鲍伟华
提交者:
彭勇升 pengys
8月 09, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimize code structure to economize computing resources (#1536)
* 优化代码结构,减少不必要的计算,节省计算资源 * 优化代码结构,减少不必要的计算,节省计算资源
上级
42028e60
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
4 deletion
+21
-4
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
...rker/global/std/ResponseTimeDistributionSpanListener.java
+5
-4
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/test/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionSpanListenerTestCase.java
...bal/std/ResponseTimeDistributionSpanListenerTestCase.java
+1
-0
apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IResponseTimeDistributionConfigService.java
...ation/service/IResponseTimeDistributionConfigService.java
+8
-0
apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ResponseTimeDistributionConfigService.java
...ration/service/ResponseTimeDistributionConfigService.java
+7
-0
未找到文件。
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
浏览文件 @
6db0d08f
...
...
@@ -73,15 +73,16 @@ public class ResponseTimeDistributionSpanListener implements FirstSpanListener {
}
int
getStep
(
int
duration
)
{
int
countOfResponseTimeSteps
=
configService
.
getResponseTimeStep
()
*
configService
.
getCountOfResponseTimeSteps
();
int
responseTimeStep
=
configService
.
getResponseTimeStep
();
int
countOfResponseTimeSteps
=
configService
.
getCountOfResponseTimeSteps
();
int
totalTimeOfResponseTimeSteps
=
configService
.
getTotalTimeOfResponseTimeSteps
();
if
(
duration
>
count
OfResponseTimeSteps
)
{
return
countOfResponseTimeSteps
/
responseTimeStep
;
if
(
duration
>
totalTime
OfResponseTimeSteps
)
{
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
;
}
}
...
...
apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/test/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionSpanListenerTestCase.java
浏览文件 @
6db0d08f
...
...
@@ -42,6 +42,7 @@ public class ResponseTimeDistributionSpanListenerTestCase {
IResponseTimeDistributionConfigService
service
=
Mockito
.
mock
(
IResponseTimeDistributionConfigService
.
class
);
Mockito
.
when
(
service
.
getResponseTimeStep
()).
thenReturn
(
50
);
Mockito
.
when
(
service
.
getCountOfResponseTimeSteps
()).
thenReturn
(
40
);
Mockito
.
when
(
service
.
getTotalTimeOfResponseTimeSteps
()).
thenReturn
(
2050
);
ModuleDefine
module
=
Mockito
.
mock
(
ModuleDefine
.
class
);
Whitebox
.
setInternalState
(
module
,
"loadedProviders"
,
loadedProviders
);
...
...
apm-collector/apm-collector-configuration/collector-configuration-define/src/main/java/org/apache/skywalking/apm/collector/configuration/service/IResponseTimeDistributionConfigService.java
浏览文件 @
6db0d08f
...
...
@@ -28,4 +28,12 @@ public interface IResponseTimeDistributionConfigService extends Service {
int
getResponseTimeStep
();
int
getCountOfResponseTimeSteps
();
/**
* Equals to getResponseTimeStep() * getCountOfResponseTimeSteps() ,just for economizes computing resources
*
* @return
*/
int
getTotalTimeOfResponseTimeSteps
();
}
apm-collector/apm-collector-configuration/collector-configuration-provider/src/main/java/org/apache/skywalking/apm/collector/configuration/service/ResponseTimeDistributionConfigService.java
浏览文件 @
6db0d08f
...
...
@@ -25,10 +25,12 @@ public class ResponseTimeDistributionConfigService implements IResponseTimeDistr
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 class ResponseTimeDistributionConfigService implements IResponseTimeDistr
@Override
public
int
getCountOfResponseTimeSteps
()
{
return
countOfResponseTimeSteps
;
}
@Override
public
int
getTotalTimeOfResponseTimeSteps
()
{
return
totalTimeOfResponseTimeSteps
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录