-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathLatencyTest.java
91 lines (74 loc) · 3.01 KB
/
LatencyTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package com.redislabs.redisgraph;
import com.redislabs.redisgraph.impl.api.ContextedRedisGraph;
import com.redislabs.redisgraph.impl.api.RedisGraph;
import com.redislabs.redisgraph.impl.graph_cache.GraphCache;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.concurrent.CopyOnWriteArrayList;
public class LatencyTest {
private RedisGraphContextGenerator api;
// @Before
// public void createApi(){
// api = new RedisGraph("172.26.81.242", 7000);
// }
// @After
// public void deleteGraph() {
//
// api.deleteGraph("social");
// api.close();
// }
@Test
public void testLatency(){
api.query("social", "CREATE(:N {a:1})-[:E]->(:N2{b:2})");
long startTime = System.nanoTime();
api.query("social", "MATCH(n1)-[e]->(n2) RETURN *");
long stopTime = System.nanoTime();
System.out.println((stopTime - startTime)/1000000);
startTime = System.nanoTime();
api.query("social", "MATCH(n1)-[e]->(n2) RETURN *");
stopTime = System.nanoTime();
System.out.println((stopTime - startTime)/1000000);
}
@Test
public void testContextLatency() {
api.query("social", "CREATE(:N {a:1})-[:E]->(:N2{b:2})");
ContextedRedisGraph context = (ContextedRedisGraph) api.getContext();
long startTime = System.nanoTime();
context.query("social", "MATCH(n1)-[e]->(n2) RETURN *");
long stopTime = System.nanoTime();
System.out.println((stopTime - startTime)/1000000);
startTime = System.nanoTime();
context.query("social", "MATCH(n1)-[e]->(n2) RETURN *");
stopTime = System.nanoTime();
System.out.println((stopTime - startTime)/1000000);
api.query("social2", "CREATE(:N {a:1})-[:E]->(:N2{b:2})");
context = (ContextedRedisGraph) api.getContext();
startTime = System.nanoTime();
context.query("social2", "MATCH(n1)-[e]->(n2) RETURN *");
stopTime = System.nanoTime();
System.out.println((stopTime - startTime)/1000000);
startTime = System.nanoTime();
context.query("social2", "MATCH(n1)-[e]->(n2) RETURN *");
stopTime = System.nanoTime();
System.out.println((stopTime - startTime)/1000000);
}
@Test
public void testCacheCreationLatency(){
long startTime = System.nanoTime();
// CopyOnWriteArrayList[] lists = new CopyOnWriteArrayList[6];
// for (int i=0; i < 3; i++){
// lists[i] = new CopyOnWriteArrayList<>();
// }
new GraphCache("1");
long stopTime = System.nanoTime();
System.out.println((stopTime - startTime)/1000000);
startTime = System.nanoTime();
// for (int i=0; i < 3; i++){
// lists[i+3] = new CopyOnWriteArrayList<>();
// }
new GraphCache("2");
stopTime = System.nanoTime();
System.out.println((stopTime - startTime)/1000000);
}
}