int useCache(SolrCache sc,int numGets,int maxKey,int seed){
  int ret=0;
  Random r=new Random(seed);
  for (int i=0; i < numGets; i++) {
    Integer k=r.nextInt(maxKey);
    Integer v=(Integer)sc.get(k);
    if (v == null) {
      sc.put(k,k);
      ret++;
    }
  }
  return ret;
}

int useCache ( SolrCache sc , int numGets , int maxKey , int seed ) { int ret = 0 ; Random r = new Random ( seed ) ; for ( int i = 0 ; i < numGets ; i ++ ) { Integer k = r . nextInt ( maxKey ) ; Integer v = ( Integer ) sc . get ( k ) ; if ( v == null ) { sc . put ( k , k ) ; ret ++ ; } } return ret ; }
public void testperf ( ) { doperftest ( 1000000 , 100000 , 200000 ) ; / / big cache , warmup doperftest ( 2000000 , 100000 , 200000 ) ; / / big cache doperftest ( 2000000 , 100000 , 120000 ) ; / / smaller key space increases distance between oldest , newest and makes the first passes less effective . doperftest ( 6000000 , 1000 , 2000 ) ; / / small cache , smaller hit rate doperftest ( 6000000 , 1000 , 1200 ) ; / / small cache , bigger hit rate }
