Skip to content

Commit b949746

Browse files
author
Daniel Bustamante Ospina
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # async/async-commons/async-commons.gradle # async/async-commons/src/test/java/org/reactivecommons/async/impl/utils/matcher/KeyMatcherPerformanceTest.java
2 parents 8a3e3de + 19c98bf commit b949746

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

async/async-commons/async-commons.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ dependencies {
7979
api ("io.projectreactor.rabbitmq:reactor-rabbitmq")
8080
api 'com.fasterxml.jackson.core:jackson-databind'
8181
testImplementation 'io.projectreactor:reactor-test'
82-
testCompile group: 'org.databene', name: 'contiperf', version: '2.3.4'
83-
82+
testCompile group: 'com.github.javatlacati', name: 'contiperf', version: '2.4.3'
8483
}
8584

8685
configurations.all {
Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,51 @@
11
package org.reactivecommons.async.impl.utils.matcher;
22

3-
import org.databene.contiperf.PerfTest;
4-
import org.databene.contiperf.Required;
5-
import org.databene.contiperf.junit.ContiPerfRule;
3+
import com.github.javatlacati.contiperf.PerfTest;
4+
import com.github.javatlacati.contiperf.Required;
5+
import com.github.javatlacati.contiperf.junit.ContiPerfRule;
66
import org.junit.Before;
7-
import org.junit.BeforeClass;
87
import org.junit.Rule;
98
import org.junit.Test;
9+
import org.junit.jupiter.api.BeforeAll;
1010
import org.junit.runner.RunWith;
1111
import org.springframework.test.context.ContextConfiguration;
1212
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
1313

1414
import java.io.File;
1515
import java.io.IOException;
16+
import java.net.URI;
17+
import java.net.URISyntaxException;
1618
import java.nio.file.Files;
1719
import java.nio.file.Paths;
18-
import java.util.HashMap;
19-
import java.util.HashSet;
20-
import java.util.Map;
21-
import java.util.Set;
20+
import java.util.*;
21+
import java.util.concurrent.atomic.AtomicBoolean;
22+
import java.util.concurrent.atomic.AtomicReference;
2223
import java.util.stream.Collectors;
2324

24-
@ContextConfiguration(classes = KeyMatcher.class)
25-
@RunWith(SpringJUnit4ClassRunner.class)
2625
public class KeyMatcherPerformanceTest {
27-
2826
@Rule
2927
public ContiPerfRule contiPerfRule = new ContiPerfRule();
30-
static Map<String, String> candidates = new HashMap<>();
31-
28+
public static AtomicReference<Map<String, String>> candidates = new AtomicReference<>();
29+
public static AtomicBoolean initialized = new AtomicBoolean(false);
3230
private KeyMatcher keyMatcher = new KeyMatcher();
31+
private String DATASET_FILENAME = "candidateNamesForMatching.txt";
3332

34-
35-
@BeforeClass
36-
public static void init() {
37-
ClassLoader classLoader = KeyMatcherPerformanceTest.class.getClassLoader();
38-
File file = new File(classLoader.getResource("candidateNamesForMatching.txt").getFile());
39-
try {
40-
Set<String> names = new HashSet<>(Files
41-
.readAllLines(Paths.get(file.getAbsolutePath())));
42-
candidates = names.stream()
43-
.collect(Collectors.toMap(name -> name, name -> name));
44-
} catch (IOException e) {
45-
e.printStackTrace();
33+
@Before
34+
public void init() {
35+
if (!initialized.get()) {
36+
initialized.set(true);
37+
try {
38+
ClassLoader classLoader = KeyMatcherPerformanceTest.class.getClassLoader();
39+
File file = new File(Objects.requireNonNull(classLoader.getResource(DATASET_FILENAME))
40+
.getFile());
41+
Set<String> names = new HashSet<>(Files
42+
.readAllLines(Paths.get(file.getAbsolutePath())));
43+
candidates.set(names.stream()
44+
.collect(Collectors.toMap(name -> name, name -> name)));
45+
} catch (IOException e) {
46+
e.printStackTrace();
47+
candidates.set(new HashMap<>());
48+
}
4649
}
4750
}
4851

@@ -51,14 +54,13 @@ public static void init() {
5154
@Required(average = 200, max = 10000, throughput = 200)
5255
public void getFromMapTest() {
5356
String existentKey = "System.segment.3073.event.action";
54-
candidates.get(existentKey);
57+
candidates.get().get(existentKey);
5558
}
5659

57-
5860
@Test
5961
@PerfTest(threads = 4, duration = 4000)
6062
@Required(average = 200, max = 10000, throughput = 200)
6163
public void matchNameBeforeTest() {
62-
keyMatcher.match(candidates.keySet(), "System.segment.1.event.action");
64+
keyMatcher.match(candidates.get().keySet(), "System.segment.1.event.action");
6365
}
6466
}

0 commit comments

Comments
 (0)