Test fast loading speed. It's speedy!

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2481 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2003-04-27 06:38:48 +00:00
parent 21889f5a9e
commit 278b04206c
@@ -1,5 +1,5 @@
// //
// $Id: ImageLoadingSpeed.java,v 1.3 2003/04/25 15:52:39 mdb Exp $ // $Id: ImageLoadingSpeed.java,v 1.4 2003/04/27 06:38:48 mdb Exp $
package com.threerings.media; package com.threerings.media;
@@ -10,8 +10,9 @@ import javax.imageio.stream.FileImageInputStream;
import java.io.*; import java.io.*;
import com.threerings.resource.ResourceManager; import com.threerings.media.image.FastImageIO;
import com.threerings.media.image.ImageManager; import com.threerings.media.image.ImageManager;
import com.threerings.resource.ResourceManager;
/** /**
* Tests our image loading speed. * Tests our image loading speed.
@@ -21,20 +22,25 @@ public class ImageLoadingSpeed
public static void main (String[] args) public static void main (String[] args)
{ {
if (args.length < 1) { if (args.length < 1) {
System.err.println("Usage: ImageLoadingTest image [image ...]"); System.err.println("Usage: ImageLoadingTest image");
System.exit(-1);
}
File file = new File(args[0]);
File ffile = new File(args[0] + FastImageIO.FILE_SUFFIX);
try {
BufferedImage image = ImageIO.read(file);
FastImageIO.write(image, new FileOutputStream(ffile));
} catch (IOException ioe) {
ioe.printStackTrace(System.err);
System.exit(-1); System.exit(-1);
} }
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
int iter = 0; int iter = 0;
while (true) { while (true) {
String path = args[iter%args.length];
try { try {
FileImageInputStream fis = FastImageIO.read(ffile).getWidth();
new FileImageInputStream(new File(path));
BufferedImage image = ImageIO.read(fis);
int width = image.getWidth();
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(System.err); ioe.printStackTrace(System.err);
System.exit(-1); System.exit(-1);