Skip to content

Commit 36900be

Browse files
committed
[ java ] Add java's benchmark
1 parent 4e0185e commit 36900be

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ apply plugin: 'java'
1616
apply plugin: 'kotlin'
1717
apply plugin: 'jacoco'
1818

19-
sourceCompatibility = 1.6
20-
targetCompatibility = 1.6
19+
sourceCompatibility = 1.8
20+
targetCompatibility = 1.8
2121

2222
repositories {
2323
mavenCentral()
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.lice;
2+
3+
import org.junit.Test;
4+
5+
import java.util.HashMap;
6+
import java.util.Map;
7+
import java.util.function.Consumer;
8+
import java.util.function.IntConsumer;
9+
import java.util.function.ObjIntConsumer;
10+
11+
public class LiceBenchmarkJava {
12+
private Map<String, Object> map = new HashMap<>();
13+
14+
private interface TripleFunction<A, B, C, D> {
15+
D fun(A a, B b, C c);
16+
}
17+
18+
private void java() {
19+
TripleFunction<String, Object, Consumer<Map<String, Object>>, Void> function = (name, value, mapConsumer) -> {
20+
map.put(name, value);
21+
mapConsumer.accept(map);
22+
map.remove(name);
23+
return null;
24+
};
25+
function.fun("reimu", 100, it -> Integer.valueOf(233 + ((Integer) it.get("reimu"))));
26+
}
27+
28+
@Test
29+
public void main() {
30+
ObjIntConsumer<IntConsumer> loop = (f, count) -> {
31+
int i = 0;
32+
while (i < count) {
33+
f.accept(i);
34+
i = i + 1;
35+
}
36+
};
37+
loop.accept(i -> java(), Benchmark.cnt);
38+
}
39+
}

0 commit comments

Comments
 (0)