2016-12-30 52 views
2

我试图找出我的Java驱动程序的Cypher查询的执行时间。的Cypher查询执行时间与Neo4j的Java驱动程序

Session session = driver.session(); 
session.run("CREATE (a:Person {name:'Arthur', title:'King'})"); 
StatementResult result = session.run("Profile MATCH (a:Person) WHERE a.name = 'Arthur' RETURN a.name AS name, a.title AS title"); 

但我不能在StatementResultResultSummary,这是由StatementResult.consume(query)返回的任何地方找到它。

我可以从ProfiledPlan访问db命中ResultSummary,但没有关于时间的信息。

有什么办法,我可以用Neo4j的Java驱动程序访问的Cypher查询执行时间?

+0

嗨,你能简单地告诉我什么'a'在创建人之前CREATE(a:Person ...'代表,我一直都在看它,它是否类似于JPQL – qualebs

回答

2

由于Neo4j的Java驱动程序版本1.1.0有:

/** 
* The time it took the server to make the result available for consumption. 
* 
* @param unit The unit of the duration. 
* @return The time it took for the server to have the result available in the provided time unit. 
*/ 
long resultAvailableAfter(TimeUnit unit); 

/** 
* The time it took the server to consume the result. 
* 
* @param unit The unit of the duration. 
* @return The time it took for the server to consume the result in the provided time unit. 
*/ 
long resultConsumedAfter(TimeUnit unit); 

它提供了两个时间:

  1. 时间,直到第一个字节
  2. 全部执行时间包括服务器消耗数据

方法是localted上org.neo4j.driver.v1.summary.ResultSummary INTERF高手。

+0

中的statefield谢谢@arezoo你是对的,我错过了它,因为它只在最新的neo4j-java-driver 1.1.0中可用,而我正在使用1.0.5 –