[ 
https://issues.apache.org/jira/browse/SOLR-390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12537179
 ] 

Yonik Seeley commented on SOLR-390:
-----------------------------------

Doing a quick HashDocSet construction test (below) showed the loop to be 
slightly faster on average than Arrays.fill()... I have no idea why, but I'll 
close this bug for now and it can be reopened if someone comes up with a better 
test (or tests on different JVMs, etc).

{code}public class TestPerf {

  private static int VAL=-1;

  private static int go(int[] x) {
    HashDocSet ds = new HashDocSet(x,0,x.length);
    return ds.exists(1) ? 1 : 0;
  }


  public static void main(String[] args) {
    int a=0;
    int sz = Integer.parseInt(args[a++]);
    int iter = Integer.parseInt(args[a++]);
    int[] x = new int[sz];
    int[] x2 = new int[sz];
    for (int ii=0; ii<sz; ii++) {
      x[ii]=ii*1234567891;
      x2[ii]=ii*987654323;
    }

    int ret=0;
    long start = System.currentTimeMillis();
    int num=0;
    for (int i=0; i<iter; i++) {
      if (++num>=sz) num=0;
      x[num] += go(x)+ret+x2[num];
      ret += go(x2) + x2[num]++;
    }
    long end = System.currentTimeMillis();
    System.out.println("result=" + ret);
    System.out.println("time=" +(end-start));
  }
}
{code}

> HashDocSet initialization of internal array is not efficient
> ------------------------------------------------------------
>
>                 Key: SOLR-390
>                 URL: https://issues.apache.org/jira/browse/SOLR-390
>             Project: Solr
>          Issue Type: Bug
>          Components: search
>            Reporter: John Wang
>
> HashDocSet initializes the internal array but iterating it instead of using 
> Arrays.fill which is much faster. Patch included

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to