src/demo/share/java2d/J2DBench/src/j2dbench/tests/cmm/EmbeddedProfileTests.java

Print this page




  83 
  84         public final URL url;
  85         public final String abbrev;
  86         public final String description;
  87 
  88         public static IccImageResource[] values() {
  89             return new IccImageResource[]{SMALL, MEDIUM, LARGE};
  90         }
  91     }
  92 
  93     private static Option createImageList() {
  94         IccImageResource[] images = IccImageResource.values();
  95 
  96         int num = images.length;
  97 
  98         String[] names = new String[num];
  99         String[] abbrev = new String[num];
 100         String[] descr = new String[num];
 101 
 102         for (int i = 0; i < num; i++) {
 103             names[i] = images[i].toString();
 104             abbrev[i] = images[i].abbrev;
 105             descr[i] = images[i].description;
 106         }
 107 
 108          Option list = new Option.ObjectList(grpOptionsRoot,
 109                 "Images", "Input Images",
 110                 names, images, abbrev, descr, 1);
 111 
 112          return list;
 113     }
 114 
 115     public EmbeddedProfileTests(Group parent, String nodeName, String description) {
 116         super(parent, nodeName, description);
 117         addDependencies(grpOptionsRoot, true);
 118     }
 119 
 120     private static class Context {
 121         URL input;
 122 
 123         public Context(TestEnvironment env, Result res) {


 136     public void cleanupTest(TestEnvironment env, Object o) {
 137         Context ctx = (Context)o;
 138         ctx.input = null;
 139     }
 140 
 141     private static class ReadImageTest extends EmbeddedProfileTests {
 142         public ReadImageTest() {
 143             super(grpRoot, "embd_img_read", "ImageReader.read()");
 144         }
 145 
 146         public void runTest(Object octx, int numReps) {
 147             final Context ctx = (Context)octx;
 148             final URL url = ctx.input;
 149             ImageInputStream iis = null;
 150             ImageReader reader = null;
 151 
 152             try {
 153                 iis = ImageIO.createImageInputStream(url.openStream());
 154                 reader = (ImageReader) ImageIO.getImageReaders(iis).next();
 155             } catch (IOException e) {
 156                 throw new RuntimeException("Unable to run the becnhmark", e);
 157             }
 158 
 159             do {
 160                 try {
 161                     reader.setInput(iis);
 162                     BufferedImage img = reader.read(0);
 163                     reader.reset();
 164 
 165                     iis = ImageIO.createImageInputStream(url.openStream());
 166                 } catch (Exception e) {
 167                     e.printStackTrace();
 168                 }
 169             } while (--numReps >= 0);
 170         }
 171     }
 172 }


  83 
  84         public final URL url;
  85         public final String abbrev;
  86         public final String description;
  87 
  88         public static IccImageResource[] values() {
  89             return new IccImageResource[]{SMALL, MEDIUM, LARGE};
  90         }
  91     }
  92 
  93     private static Option createImageList() {
  94         IccImageResource[] images = IccImageResource.values();
  95 
  96         int num = images.length;
  97 
  98         String[] names = new String[num];
  99         String[] abbrev = new String[num];
 100         String[] descr = new String[num];
 101 
 102         for (int i = 0; i < num; i++) {
 103             names[i] = images[i].abbrev;
 104             abbrev[i] = images[i].abbrev;
 105             descr[i] = images[i].description;
 106         }
 107 
 108          Option list = new Option.ObjectList(grpOptionsRoot,
 109                 "Images", "Input Images",
 110                 names, images, abbrev, descr, 1);
 111 
 112          return list;
 113     }
 114 
 115     public EmbeddedProfileTests(Group parent, String nodeName, String description) {
 116         super(parent, nodeName, description);
 117         addDependencies(grpOptionsRoot, true);
 118     }
 119 
 120     private static class Context {
 121         URL input;
 122 
 123         public Context(TestEnvironment env, Result res) {


 136     public void cleanupTest(TestEnvironment env, Object o) {
 137         Context ctx = (Context)o;
 138         ctx.input = null;
 139     }
 140 
 141     private static class ReadImageTest extends EmbeddedProfileTests {
 142         public ReadImageTest() {
 143             super(grpRoot, "embd_img_read", "ImageReader.read()");
 144         }
 145 
 146         public void runTest(Object octx, int numReps) {
 147             final Context ctx = (Context)octx;
 148             final URL url = ctx.input;
 149             ImageInputStream iis = null;
 150             ImageReader reader = null;
 151 
 152             try {
 153                 iis = ImageIO.createImageInputStream(url.openStream());
 154                 reader = (ImageReader) ImageIO.getImageReaders(iis).next();
 155             } catch (IOException e) {
 156                 throw new RuntimeException("Unable to run the benchmark", e);
 157             }
 158 
 159             do {
 160                 try {
 161                     reader.setInput(iis);
 162                     BufferedImage img = reader.read(0);
 163                     reader.reset();
 164 
 165                     iis = ImageIO.createImageInputStream(url.openStream());
 166                 } catch (Exception e) {
 167                     e.printStackTrace();
 168                 }
 169             } while (--numReps >= 0);
 170         }
 171     }
 172 }