Issue #274 show the elapsed time during export in the output

This commit is contained in:
Jindra Pet��k
2013-08-03 09:46:16 +02:00
parent 4e0ff70b61
commit 2549f9751a
4 changed files with 27 additions and 20 deletions
@@ -542,19 +542,18 @@ public class SWF {
String directory;
List<ABCContainerTag> abcList;
boolean pcode;
String informStr;
ClassPath path;
AtomicInteger index;
int count;
boolean paralel;
AbortRetryIgnoreHandler handler;
long startTime;
long stopTime;
public ExportPackTask(AbortRetryIgnoreHandler handler, AtomicInteger index, int count, ClassPath path, ScriptPack pack, String directory, List<ABCContainerTag> abcList, boolean pcode, String informStr, boolean paralel) {
public ExportPackTask(AbortRetryIgnoreHandler handler, AtomicInteger index, int count, ClassPath path, ScriptPack pack, String directory, List<ABCContainerTag> abcList, boolean pcode, boolean paralel) {
this.pack = pack;
this.directory = directory;
this.abcList = abcList;
this.pcode = pcode;
this.informStr = informStr;
this.path = path;
this.index = index;
this.count = count;
@@ -567,12 +566,15 @@ public class SWF {
RunnableIOExResult<File> rio = new RunnableIOExResult<File>() {
@Override
public void run() throws IOException {
startTime = System.currentTimeMillis();
this.result = pack.export(directory, abcList, pcode, paralel);
stopTime = System.currentTimeMillis();
}
};
new RetryTask(rio, handler).run();
synchronized (ABC.class) {
informListeners("export", "Exported " + informStr + " script " + index.getAndIncrement() + "/" + count + " " + path);
long time=stopTime-startTime;
informListeners("export", "Exported script " + index.getAndIncrement() + "/" + count + " " + path+", "+Helper.formatTimeSec(time));
}
return null;
}
@@ -605,7 +607,7 @@ public class SWF {
}
List<MyEntry<ClassPath, ScriptPack>> packs = getAS3Packs();
for (MyEntry<ClassPath, ScriptPack> item : packs) {
Future<File> future = executor.submit(new ExportPackTask(handler, cnt, packs.size(), item.key, item.value, outdir, abcTags, isPcode, "", paralel));
Future<File> future = executor.submit(new ExportPackTask(handler, cnt, packs.size(), item.key, item.value, outdir, abcTags, isPcode,paralel));
futureResults.add(future);
}
@@ -2598,19 +2598,8 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
Main.stopWork();
long timeAfter = System.currentTimeMillis();
long timeMs = timeAfter - timeBefore;
long timeS = timeMs / 1000;
timeMs = timeMs % 1000;
long timeM = timeS / 60;
timeS = timeS % 60;
long timeH = timeM / 60;
timeM = timeM % 60;
String timeStr = "";
if (timeH > 0) {
timeStr += Helper.padZeros(timeH, 2) + ":";
}
timeStr += Helper.padZeros(timeM, 2) + ":";
timeStr += Helper.padZeros(timeS, 2) + "." + Helper.padZeros(timeMs, 3);
setStatus(translate("export.finishedin").replace("%time%", timeStr));
setStatus(translate("export.finishedin").replace("%time%", Helper.formatTimeSec(timeMs)));
}
}).start();
@@ -260,7 +260,7 @@ public class ActionPanel extends JPanel implements ActionListener {
}else{
editor.setContentType("text/flasm");
}*/
editor.setText(stripped);
editor.setText(stripped);
for (Highlighting h : disassembledHilights) {
if (h.offset == offset) {
if (h.startPos <= editor.getText().length()) {
@@ -482,4 +482,20 @@ public class Helper {
}
}
}
public static String formatTimeSec(long timeMs) {
long timeS = timeMs / 1000;
timeMs = timeMs % 1000;
long timeM = timeS / 60;
timeS = timeS % 60;
long timeH = timeM / 60;
timeM = timeM % 60;
String timeStr = "";
if (timeH > 0) {
timeStr += Helper.padZeros(timeH, 2) + ":";
}
timeStr += Helper.padZeros(timeM, 2) + ":";
timeStr += Helper.padZeros(timeS, 2) + "." + Helper.padZeros(timeMs, 3);
return timeStr;
}
}