-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.scala
47 lines (40 loc) · 1.28 KB
/
Main.scala
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
package renesca.benchmark
import renesca.{DbService, RestService, Transaction, Query}
import spray.http.BasicHttpCredentials
import Benchmark._
object Main extends App {
val credentials = BasicHttpCredentials("neo4j", "testingpw")
val renescaDb = {
val db = new DbService
db.restService = new RestService("http://localhost:7474", Some(credentials))
db
}
// only proceed if database is available and empty
val wholeGraph = renescaDb.queryWholeGraph
if (wholeGraph.nonEmpty) {
renescaDb.restService.actorSystem.shutdown()
sys.error("Database is not empty.")
}
def prepareAndCleanup[T](code: => T): T = {
try {
renescaDb.query("CREATE (:ANIMAL {name:'snake'})-[:EATS]->(:ANIMAL {name:'dog'})")
code
} finally {
renescaDb.query("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r")
}
}
val iterations = 2000
println("separateQueries, renescaChangeTracking")
for (i <- 0 until iterations) {
val durationSeparate = prepareAndCleanup {
Examples.separateQueries(renescaDb)
}
val durationChangeTracking =
prepareAndCleanup {
Examples.changeTracking(renescaDb)
}
println(s"$durationSeparate, $durationChangeTracking")
}
// shut down actor systems
renescaDb.restService.actorSystem.shutdown()
}