You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "David Smiley (JIRA)" <ji...@apache.org> on 2018/01/03 21:14:00 UTC
[jira] [Resolved] (SOLR-11805) SolrRequest elapsedTime is not
computed correctly (premature millisecond conversion)
[ https://issues.apache.org/jira/browse/SOLR-11805?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Smiley resolved SOLR-11805.
---------------------------------
Resolution: Fixed
Assignee: David Smiley
Fix Version/s: 7.3
> 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
> Assignee: David Smiley
> Priority: Minor
> Fix For: 7.3
>
>
> _(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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org