1 10 11 package net.sf.cache4j.perfomance.test; 12 13 import net.sf.cache4j.perfomance.ITest; 14 import net.sf.cache4j.perfomance.ICache; 15 16 import java.util.Random ; 17 18 24 25 public class Get implements ITest { 26 private ICache _cache; 29 private static final String NAME = "Get"; 31 32 private static Random _rnd = new Random (System.currentTimeMillis()); 33 private static int _count = 2000; 34 private static int[] _keys = new int[_count]; 35 static{ 36 for (int i = 0; i <_count; i++) { 37 _keys[i] = _rnd.nextInt(_count); 38 } 39 } 40 43 48 public void init(ICache cache) throws Exception { 49 _cache = cache; 50 for (int i = 0; i <_keys.length; i++) { 51 Object key = String.valueOf(_keys[i]); 52 _cache.put(key, key); 53 } 54 } 55 56 60 public void test() throws Exception { 61 62 for (int j = 0; j <1000; j++) { 63 for (int i = 0; i <_keys.length; i++) { 64 Object key = String.valueOf(_keys[i]); 65 Object obj = _cache.get(key); 66 } 67 } 69 71 } 72 73 76 public void destroy() { 77 _cache = null; 78 } 79 80 83 public String getTestName() { 84 return NAME; 85 } 86 87 } | Popular Tags |