You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2018/01/03 20:48:00 UTC

[jira] [Commented] (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:comment-tabpanel&focusedCommentId=16310260#comment-16310260 ] 

ASF subversion and git services commented on SOLR-11805:
--------------------------------------------------------

Commit 9586d12af4b9c89a13fc0c8ff8816173ae515d1b in lucene-solr's branch refs/heads/master from [~dsmiley]
[ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=9586d12 ]

SOLR-11805: SolrJ's SolrResponse.getElaspedTime was sometimes a millisecond off


> 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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org