public static void main(String[] args){
//createTestBashScript("testRapidSmithFiles.sh");
if(args.length < 2 && args.length > 3){
MessageGenerator.briefMessageAndExit("USAGE: -<d|w|p (d:Device, w:WireEnumerator, p:PrimitiveDefs)> <partname|familyName> [-verbose]");
}
FamilyType familyType = null;
long initial_usage, total_usage;
long start, stop;
Device dev;
WireEnumerator we;
PrimitiveDefList list;
if(args[0].equals("-w") || args[0].equals("-p")){
familyType = FamilyType.valueOf(args[1].toUpperCase());
}
// Measure Initial Heap Size
Runtime rt = Runtime.getRuntime();
System.gc();
initial_usage = rt.totalMemory() - rt.freeMemory();
// Start Timer
start = System.nanoTime();
if(args[0].equals("-d")){
dev = FileTools.loadDevice(args[1]);
}
else if(args[0].equals("-w")){
we = FileTools.loadWireEnumerator(familyType);
}
else if(args[0].equals("-p")){
list = FileTools.loadPrimitiveDefs(familyType);
}
// Stop Timer
stop = System.nanoTime();
// Measure Final Heap Size
System.gc();
total_usage = rt.totalMemory() - rt.freeMemory() - initial_usage;
// Print out header if verbose switch is passed in
if(args.length > 2 && args[2].equals("-verbose")){
System.out.println("--------------------------------------------------------------------");
System.out.println("| Family | Part Name | File Size | Heap Usage | Load Time |");
System.out.println("--------------------------------------------------------------------");
}
// Calculate file size
long fileSize = 0;
if(args[0].equals("-d")){
fileSize = new File(FileTools.getDeviceFileName(args[1])).length();
}
else if(args[0].equals("-w")){
fileSize = new File(FileTools.getWireEnumeratorFileName(familyType)).length();
}
else if(args[0].equals("-p")){
fileSize = new File(FileTools.getPrimitiveDefsFileName(familyType)).length();
}
if(args[0].equals("-d")){
System.out.printf(" %-12s %-16s %6dKB %4dMB %6.3fs\n",
familyType==null ? PartNameTools.getExactFamilyNameFromPart(args[1]) : familyType.toString().toUpperCase(),
args[1],
fileSize/1024,
total_usage/(1024*1024),
((stop-start)/1000000000.0));
}
else{
System.out.printf(" %-12s %-16s %6dKB %4.1fMB %6.3fs\n",
familyType==null ? PartNameTools.getExactFamilyNameFromPart(args[1]) : familyType.toString().toUpperCase(),
" ",
fileSize/1024,
total_usage/(1024.0*1024.0),
((stop-start)/1000000000.0));