David Smiley created SOLR-11805:
-----------------------------------
Summary: SolrRequest elapsedTime is not computed correctly
(premature millisecond conversion)
Key: SOLR-11805
URL: https://issues.apache.org/jira/browse/SOLR-11805
Project: Solr
Issue Type: Improvement
Security Level: Public (Default Security Level. Issues are Public)
Reporter: David Smiley
Priority: Minor
_(this is not QTime, this is what the SolrJ client request duration is captured
as)_
This is what {{SolrRequest.process}} looks like:
{code:java}
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(),
TimeUnit.NANOSECONDS);
T res = createResponse(client);
res.setResponse(client.request(this, collection));
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(),
TimeUnit.NANOSECONDS);
res.setElapsedTime(endTime - startTime);
return res;
{code}
The millisecond conversion should be delayed to the very end, otherwise it
could yield a time duration of a millisecond greater than it deserves. Also,
it's better to put the unit into the variable name. Also, note the convenience
methods on TimeUnit like "toMillis". Here's what this should look like:
{code:java}
long startNanos = System.nanoTime();
T res = createResponse(client);
res.setResponse(client.request(this, collection));
long endNanos = System.nanoTime();
res.setElapsedTime(TimeUnit.NANOSECONDS.toMillis(endNanos - startNanos));
return res;
{code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]