简体   繁体   中英

How to get response time on d2r-query of D2RQ?

I'm using d2r-query of D2RQ to make some SPARQL Query, I'm using commande line. Please, how can I get a response time?

d2r-query myMappedData.ttl "SELECT * {?s ?p ?o} LIMIT 1000"

Is there other tools to use to get the response time?

Hi I have found a solution and I would shar it with you. So you should edit the d2_quey.java file and get the date before and after the query code treatment and calculate the timeAfterTreatment - timeBeforeTreatment

Like the code bellow:

Object objStartTime=System.currentTimeMillis(); 
Long startTime=(objStartTime==null)?0:(Long)objStartTime;       

Before this code (Treatment query)

QueryEngineD2RQ.register();
Query q = QueryFactory.create(query, loader.getResourceBaseURI());
QueryExecution qe = QueryExecutionFactory.create(q, d2rqModel);
if (timeout > 0) {
        qe.setTimeout(Math.round(timeout * 1000));
}
QueryExecUtils.executeQuery(q, qe, ResultsFormat.lookup(format));

And add this code in the end

Object objEndTime=System.currentTimeMillis();
Long endTime=(objEndTime==null)?0:(Long)objEndTime;
Long totalTime = endTime - startTime;
// display response time
System.out.println("============================================");
System.out.println("Response time : "+totalTime+" ms ");
System.out.println("============================================");

Good luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM