Skip to content

Commit

Permalink
Log form processing timings; Improve related code quality (getodk#1529)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcbriccetti authored and lognaturel committed Oct 19, 2017
1 parent cddd425 commit d73d536
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2603,13 +2603,16 @@ public void loadingComplete(FormLoaderTask task) {
}
}

// if somehow we end up with a bad language, set it to the default
long start = System.currentTimeMillis();
Timber.i("calling formController.setLanguage");
try {
formController.setLanguage(newLanguage);
} catch (Exception e) {
// if somehow we end up with a bad language, set it to the default
Timber.e("Ended up with a bad language. %s", newLanguage);
formController.setLanguage(defaultLanguage);
}
Timber.i("Done in %.3f seconds.", (System.currentTimeMillis() - start) / 1000F);
}

boolean pendingActivityResult = task.hasPendingActivityResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;

import timber.log.Timber;
Expand Down Expand Up @@ -93,7 +94,7 @@ protected HashMap<FormDetails, String> doInBackground(ArrayList<FormDetails>...
Collect.getInstance().getActivityLogger().logAction(this, "downloadForms",
String.valueOf(total));

HashMap<FormDetails, String> result = new HashMap<FormDetails, String>();
final HashMap<FormDetails, String> result = new HashMap<>();

for (FormDetails fd : toDownload) {
publishProgress(fd.formName, String.valueOf(count), String.valueOf(total));
Expand Down Expand Up @@ -149,7 +150,15 @@ protected HashMap<FormDetails, String> doInBackground(ArrayList<FormDetails>...
}

try {
checkForBadSubmissionUrl(fileResult);
if (fileResult != null) {
final long start = System.currentTimeMillis();
Timber.i("Starting an extra parse to check for a bad submission URL. %s",
fileResult.file.getAbsolutePath());
// todo can we avoid this extra parse? It can run a long time.
checkForBadSubmissionUrl(fileResult);
Timber.i("Parse finished in %.3f seconds.",
(System.currentTimeMillis() - start) / 1000F);
}
} catch (IllegalArgumentException e) {
message += e.getMessage();
}
Expand Down Expand Up @@ -272,8 +281,10 @@ private UriResult findExistingOrCreateNewUri(File formFile) throws TaskCancelled
v.put(FormsColumns.FORM_MEDIA_PATH, mediaPath);

Timber.w("Parsing document %s", formFile.getAbsolutePath());

HashMap<String, String> formInfo = FileUtils.parseXML(formFile);
final long start = System.currentTimeMillis();
Map<String, String> formInfo = FileUtils.parseXML(formFile);
Timber.i("Parse finished in %.3f seconds.",
(System.currentTimeMillis() - start) / 1000F);

if (isCancelled()) {
throw new TaskCancelledException(formFile, "Form " + formFile.getName()
Expand Down
Loading

0 comments on commit d73d536

Please sign in to comment.