//
// $Id: ImageLoadingSpeed.java,v 1.3 2003/04/25 15:52:39 mdb Exp $

package com.threerings.media;

import java.awt.Image;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.imageio.stream.FileImageInputStream;

import java.io.*;

import com.threerings.resource.ResourceManager;
import com.threerings.media.image.ImageManager;

/**
 * Tests our image loading speed.
 */
public class ImageLoadingSpeed
{
    public static void main (String[] args)
    {
        if (args.length < 1) {
            System.err.println("Usage: ImageLoadingTest image [image ...]");
            System.exit(-1);
        }

        long start = System.currentTimeMillis();
        int iter = 0;
        while (true) {
            String path = args[iter%args.length];

            try {
                FileImageInputStream fis =
                    new FileImageInputStream(new File(path));
                BufferedImage image =  ImageIO.read(fis);
                int width = image.getWidth();
            } catch (IOException ioe) {
                ioe.printStackTrace(System.err);
                System.exit(-1);
            }

            if (++iter == 100) {
                long now = System.currentTimeMillis();
                long elapsed = now - start;
                System.err.println("Loaded " + args.length +
                                   " images a total of " + iter +
                                   " times in " + elapsed + "ms.");
                System.err.println("An average of " + (elapsed/iter) +
                                   "ms per image.");

                System.gc();
                try { Thread.sleep(1000); } catch (Throwable t) {}

                start = now;
                iter = 0;
            }
        }
    }
}

@@ -31,17 +31,17 @@
 ava,v 1.
-3
+4
  2003/04
@@ -46,18 +46,18 @@
 04/2
-5 15:52:39
+7 06:38:48
  mdb
@@ -281,32 +281,31 @@
 ngs.
-resource.ResourceManager
+media.image.FastImageIO
 ;%0Aim
@@ -349,16 +349,64 @@
 Manager;
+%0Aimport com.threerings.resource.ResourceManager;
 %0A%0A/**%0A *
@@ -620,20 +620,8 @@
 mage
- %5Bimage ...%5D
 %22);%0A
@@ -672,265 +672,347 @@
     
-long start = System.currentTimeMillis();%0A        int iter = 0;%0A        while (true) %7B%0A            String path = args%5Biter%25args.length%5D;%0A%0A            try %7B%0A                FileImageInputStream fis =%0A                    new FileImageInputStream(new File(path)
+File file = new File(args%5B0%5D);%0A        File ffile = new File(args%5B0%5D + FastImageIO.FILE_SUFFIX);%0A        try %7B%0A            BufferedImage image = ImageIO.read(file);%0A            FastImageIO.write(image, new FileOutputStream(ffile));%0A        %7D catch (IOException ioe) %7B%0A            ioe.printStackTrace(System.err);%0A            System.exit(-1
 );%0A 
@@ -1014,32 +1014,35 @@
 1);%0A        
+%7D%0A%0A
         
 BufferedImag
@@ -1033,47 +1033,46 @@
     
-BufferedImage image =  ImageIO.read(f
+long start = System.currentTimeMill
 is
+(
 );%0A 
@@ -1082,33 +1082,102 @@
     
-        int width = image
+int iter = 0;%0A        while (true) %7B%0A            try %7B%0A                FastImageIO.read(ffile)
 .get

Test fast loading speed. It's speedy!