Added ram usage test

git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@435 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
Jared Gould 2007-01-17 17:26:05 +00:00
parent 91291868d3
commit fdfa27cafb
3 changed files with 64 additions and 8 deletions

View File

@ -359,6 +359,7 @@ public class RomDefinitionHandler extends DefaultHandler {
} }
// Set all other attributes // Set all other attributes
System.out.println(attr.getValue(ATTR_USER_LEVEL));
if (attr.getIndex(ATTR_USER_LEVEL) > -1) if (attr.getIndex(ATTR_USER_LEVEL) > -1)
switchGroup.setUserLevel(parseInt(attr.getValue(ATTR_USER_LEVEL))); switchGroup.setUserLevel(parseInt(attr.getValue(ATTR_USER_LEVEL)));

View File

@ -22,6 +22,7 @@
package enginuity.newmaps.definition.index; package enginuity.newmaps.definition.index;
import enginuity.newmaps.definition.RomDefinitionHandler; import enginuity.newmaps.definition.RomDefinitionHandler;
import enginuity.newmaps.ecudata.Rom;
import enginuity.newmaps.xml.SaxParserFactory; import enginuity.newmaps.xml.SaxParserFactory;
import static enginuity.util.MD5Checksum.getMD5Checksum; import static enginuity.util.MD5Checksum.getMD5Checksum;
import enginuity.util.exception.NameableNotFoundException; import enginuity.util.exception.NameableNotFoundException;
@ -30,7 +31,9 @@ import org.xml.sax.SAXParseException;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
@ -159,7 +162,7 @@ public class IndexBuilder {
public static void testMemUsage() { public static void testMemUsage() {
try { try {
File dir = new File("/newdefs"); File dir = new File("/newdefs");
//File dir = new File("/netbeans/enginuity/xmltest"); //File dir = new File("./xmltest");
Index index = getIndex(dir); Index index = getIndex(dir);
RomDefinitionHandler handler = new RomDefinitionHandler(index); RomDefinitionHandler handler = new RomDefinitionHandler(index);
@ -172,25 +175,50 @@ public class IndexBuilder {
InputStream inputStream1 = new BufferedInputStream(new FileInputStream(item.getFile())); InputStream inputStream1 = new BufferedInputStream(new FileInputStream(item.getFile()));
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
SaxParserFactory.getSaxParser().parse(inputStream1, handler); SaxParserFactory.getSaxParser().parse(inputStream1, handler);
//System.out.println(handler.getRom());
time += (System.currentTimeMillis() - start); time += (System.currentTimeMillis() - start);
saveDef(handler.getRom());
} }
System.out.println(handler.getRom());
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
}
public static void saveDef(Rom rom) {
try {
FileOutputStream fileOut = new FileOutputStream("/sizetest/" + rom.getName() + ".dat");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
System.out.println("Writing Hashtable Object...");
out.writeObject(rom);
System.out.println("Closing all output streams...\n");
out.close();
fileOut.close();
} catch(FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} }
public static void main(String[] args) { public static void main(String[] args) {
/*try { /*try {
File file = new File("/netbeans/enginuity/xmltest"); //File file = new File("/newdefs");
IndexBuilder b = new IndexBuilder(file, IndexUtil.getIndex(file)); File file = new File("./xmltest");
IndexBuilder b = new IndexBuilder(file, getIndex(file));
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} */ } */
testMemUsage(); testMemUsage();
} }
} }

View File

@ -12,7 +12,10 @@ import enginuity.maps.TableSwitch;
import enginuity.newmaps.xml.XmlHelper; import enginuity.newmaps.xml.XmlHelper;
import enginuity.util.HexUtil; import enginuity.util.HexUtil;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -27,6 +30,24 @@ public class DefinitionBuilder {
Document doc; Document doc;
int num = 0; int num = 0;
public void saveRom(Rom rom) {
try {
FileOutputStream fileOut = new FileOutputStream("/sizetest/" + rom.getRomIDString() + ".dat");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
System.out.println("Writing Hashtable Object...");
out.writeObject(rom);
System.out.println("Closing all output streams...\n");
out.close();
fileOut.close();
} catch(FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public DefinitionBuilder(Vector<Rom> roms, File folder) { public DefinitionBuilder(Vector<Rom> roms, File folder) {
this.roms = roms; this.roms = roms;
OutputFormat of = new OutputFormat("XML", "ISO-8859-1", true); OutputFormat of = new OutputFormat("XML", "ISO-8859-1", true);
@ -41,9 +62,15 @@ public class DefinitionBuilder {
// //
Iterator it = roms.iterator(); Iterator it = roms.iterator();
while (it.hasNext()) { while (it.hasNext()) {
Rom rom = (Rom)it.next(); Rom rom = (Rom)it.next();
Vector<Table> tables = rom.getTables(); Vector<Table> tables = rom.getTables();
//
/* MEMORY USAGE TEST -- REMOVE LATER! */
//
saveRom(rom);
// Build rom info // Build rom info
parentRom = null; parentRom = null;
Element node = buildRom(rom); Element node = buildRom(rom);