Skip to content

Commit 6968478

Browse files
committed
add multiplication-table to perf-test
1 parent 0b92a96 commit 6968478

File tree

6 files changed

+54
-1
lines changed

6 files changed

+54
-1
lines changed

src/test/java/j2html/comparison/ComparisonData.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ public static List<Employee> fiveHundredEmployees() {
1111
return IntStream.range(0, 500).mapToObj(i -> new Employee(i, "Some name", "Some title")).collect(Collectors.toList());
1212
}
1313

14+
public static List<Integer> tableNumbers = IntStream.range(1, 51).boxed().collect(Collectors.toList());
15+
1416
}
1517

src/test/java/j2html/comparison/RenderPerformanceComparisonTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ public void j2htmlPerformance() throws Exception {
2020
TestJ2html.helloWorld();
2121
TestJ2html.fiveHundredEmployees();
2222
TestJ2html.macros();
23+
TestJ2html.multiplicationTable();
2324
}
2425

2526
@Test
2627
public void velocityPerformance() throws Exception {
2728
TestVelocity.helloWorld();
2829
TestVelocity.fiveHundredEmployees();
2930
TestVelocity.macros();
31+
TestVelocity.multiplicationTable();
3032
}
3133

3234
}

src/test/java/j2html/comparison/TestJ2html.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package j2html.comparison;
22

3-
import j2html.comparison.j2html.HelloWorld;
43
import j2html.comparison.j2html.FiveHundredEmployees;
4+
import j2html.comparison.j2html.HelloWorld;
55
import j2html.comparison.j2html.Macros;
6+
import j2html.comparison.j2html.MultiplicationTable;
67

78
public class TestJ2html {
89

@@ -18,5 +19,12 @@ public static String macros() {
1819
return Macros.tag.render();
1920
}
2021

22+
public static String multiplicationTable() {
23+
return MultiplicationTable.tag.render();
24+
}
25+
26+
public static void main(String[] args) {
27+
System.out.println(MultiplicationTable.tag.renderFormatted());
28+
}
2129

2230
}

src/test/java/j2html/comparison/TestVelocity.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,14 @@ public static String macros() {
3939
return render("/comparison/velocity/macros.vm", null);
4040
}
4141

42+
public static String multiplicationTable() {
43+
Map<String, Object> model = new HashMap<>();
44+
model.put("tableNumbers", ComparisonData.tableNumbers);
45+
return render("/comparison/velocity/multiplicationTable.vm", model);
46+
}
47+
48+
public static void main(String[] args) {
49+
System.out.println(multiplicationTable());
50+
}
51+
4252
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package j2html.comparison.j2html;
2+
3+
import j2html.comparison.ComparisonData;
4+
import j2html.tags.ContainerTag;
5+
import static j2html.TagCreator.*;
6+
7+
public class MultiplicationTable {
8+
9+
public static ContainerTag tag = table(
10+
tbody(
11+
each(ComparisonData.tableNumbers, i -> tr(
12+
each(ComparisonData.tableNumbers, j -> td(
13+
String.valueOf(i * j)
14+
))
15+
))
16+
)
17+
);
18+
19+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<table>
2+
<tbody>
3+
#foreach($i in $tableNumbers)
4+
<tr>
5+
#foreach($j in $tableNumbers)
6+
#set($product = $i * $j)
7+
<td>$product</td>
8+
#end
9+
</tr>
10+
#end
11+
</tbody>
12+
</table>

0 commit comments

Comments
 (0)