sparqlrdfjenad2rq

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?


Solution

  • 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