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:
@@ -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;
|
||||
|
||||
@@ -10,8 +10,9 @@ import javax.imageio.stream.FileImageInputStream;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import com.threerings.resource.ResourceManager;
|
||||
import com.threerings.media.image.FastImageIO;
|
||||
import com.threerings.media.image.ImageManager;
|
||||
import com.threerings.resource.ResourceManager;
|
||||
|
||||
/**
|
||||
* Tests our image loading speed.
|
||||
@@ -21,20 +22,25 @@ public class ImageLoadingSpeed
|
||||
public static void main (String[] args)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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();
|
||||
FastImageIO.read(ffile).getWidth();
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace(System.err);
|
||||
System.exit(-1);
|
||||
|
||||
Reference in New Issue
Block a user