1 19 package gnu.trove.benchmark; 20 21 class Repeater implements Timer { 22 int _count; 23 Operation _operation; 24 25 Repeater(Operation o) { 26 _count = o.getIterationCount(); 27 _operation = o; 28 } 29 30 public Result run() { 31 long theirs = theirs(); 32 long ours = ours(); 33 Result r = new Result(); 34 r.setTheirs(theirs); 35 r.setOurs(ours); 36 r.setIterations(_count); 37 r.setDescription(_operation.toString()); 38 return r; 39 } 40 41 public long theirs() { 42 long then = System.currentTimeMillis(); 43 for (int i = 0; i < _count; i++) { 44 _operation.theirs(); 45 } 46 long now = System.currentTimeMillis(); 47 return (now -then); 48 } 49 50 public long ours() { 51 long then = System.currentTimeMillis(); 52 for (int i = 0; i < _count; i++) { 53 _operation.ours(); 54 } 55 long now = System.currentTimeMillis(); 56 return (now -then); 57 } 58 59 public Operation getOperation() { 60 return _operation; 61 } 62 } 63 | Popular Tags |