1 11 package org.eclipse.test.internal.performance.data; 12 13 import org.eclipse.test.internal.performance.InternalDimensions; 14 import org.eclipse.test.internal.performance.PerformanceTestPlugin; 15 import org.eclipse.test.performance.Dimension; 16 17 20 public class Dim implements Dimension { 21 22 private static Dim[] fgRegisteredDimensions= new Dim[100]; 23 24 private final int fId; 25 private final Unit fUnit; 26 private final int fMultiplier; 27 private final boolean fLargerIsBetter= false; 29 public static Dim getDimension(int id) { 30 InternalDimensions.COMITTED.getId(); if (id >= 0 && id < fgRegisteredDimensions.length) 32 return fgRegisteredDimensions[id]; 33 return null; 34 } 35 36 public Dim(int id) { 37 this(id, Unit.CARDINAL, 1); 38 } 39 40 public Dim(int id, Unit unit) { 41 this(id, unit, 1); 42 } 43 44 public Dim(int id, Unit unit, int multiplier) { 45 46 if (id >= 0 && id < fgRegisteredDimensions.length) { 47 if (fgRegisteredDimensions[id] == null) { 48 fgRegisteredDimensions[id]= this; 49 } else 50 PerformanceTestPlugin.logError("dimension with id '" + id + "' already registered"); } 52 fId= id; 53 fUnit= unit; 54 fMultiplier= multiplier; 55 } 56 57 public int getId() { 58 return fId; 59 } 60 61 public Unit getUnit() { 62 return fUnit; 63 } 64 65 public int getMultiplier() { 66 return fMultiplier; 67 } 68 69 public boolean largerIsBetter() { 70 return fLargerIsBetter; 71 } 72 73 public String getName() { 74 return DimensionMessages.getString(fId); 75 } 76 77 public String toString() { 78 return "Dimension [name=" + getName() + ", " + fUnit + "]"; } 80 81 public String getDisplayValue(Scalar scalar) { 82 return fUnit.getDisplayValue1(scalar.getMagnitude(), fMultiplier); 83 } 84 85 public String getDisplayValue(double scalar) { 86 return fUnit.getDisplayValue1(scalar / fMultiplier); 87 } 88 } 89 | Popular Tags |