Skip to content

响应时间超过1秒时,ftl脚本输出数字会包含逗号如:1000.00 =>html 1,000.00、 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public PerfConfigContext(ExtensionContext context) {
public List<Extension> getAdditionalExtensions() {
return Collections.singletonList(
(TestInstancePostProcessor) (testInstance, context) -> {
final Class clazz = testInstance.getClass();
final Class<?> clazz = testInstance.getClass();
// Group test contexts by test class
ACTIVE_CONTEXTS.putIfAbsent(clazz, new ArrayList<>());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.github.houbb.junitperf.support.builder.EvaluationResultBuilder;

import org.apiguardian.api.API;
import org.junit.jupiter.api.DisplayName;

import java.io.Serializable;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -44,6 +45,12 @@ public class EvaluationContext implements Serializable {
*/
private final String methodName;

/**
* 方法展示名称
* @see org.junit.jupiter.api.DisplayName
*/
private final DisplayName displayName;

/**
* 开始时间
*/
Expand Down Expand Up @@ -76,6 +83,7 @@ public EvaluationContext(final Object testInstance,
this.testInstance = testInstance;
this.testMethod = testMethod;
this.methodName = testMethod.getName();
this.displayName = testMethod.getAnnotation(DisplayName.class);
this.startTime = startTime;
}

Expand Down Expand Up @@ -139,6 +147,15 @@ public Method getTestMethod() {
return testMethod;
}

/**
* 获取显示名称
* 有指定显示名称的话,使用显示名称
* @see DisplayName
*/
public String getDisplayName() {
return displayName == null ? methodName : displayName.value();
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/templates/report.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@
<#assign active = (context_index==0) ? string("active", "")>
<#if context.evaluationResult.isSuccessful()>
<li title="${context.methodName}" class="borderRightSuccess ${active}">
<a href='#${context.methodName}'>${context.methodName}</a>
<a href='#${context.methodName}'>${context.displayName}</a>
</li>
<#else>
<li title="${context.methodName}" class="borderRightFail ${active}">
<a href='#${context.methodName}'>${context.methodName}</a>
<a href='#${context.methodName}'>${context.displayName}</a>
</li>
</#if>
</#list>
Expand All @@ -207,7 +207,7 @@
<#list contextData as context>

<div id="${context.methodName}" class="test-method">
<span title="${context.methodName}" class="test-method-name">${context.methodName}</span>
<span title="${context.methodName}" class="test-method-name">${context.displayName}</span>

<div id="${context.methodName}-img" class="test-method-img">
<!-- ADD scatter Chart here!! -->
Expand All @@ -219,7 +219,7 @@
var data = google.visualization.arrayToDataTable([
['Percentile', 'Latency', {role: "tooltip"}],
<#list 1..100 as i>
[ ${i}, ${context.statisticsCalculator.getLatencyPercentile(i, milliseconds)} , "${i}% of executions ≤ ${context.statisticsCalculator.getLatencyPercentile(i, milliseconds)}ms"],
[ ${i}, ${context.statisticsCalculator.getLatencyPercentile(i, milliseconds)?c} , "${i}% of executions ≤ ${context.statisticsCalculator.getLatencyPercentile(i, milliseconds)}ms"],
</#list>
]);
var options = {
Expand Down