Hi Dave,
Thank you for looking at this.
Here is the code I use ('plug' == 'plugin') :
// ================= DS code for the bench ===================
function bench(dir) {
console.time("bench plug");
let result = JSON.parse(plug.ListFolder(dir));
console.log("plug got " + result.length);
console.timeEnd("bench plug");
console.time("bench app");
let la = app.ListFolder(dir);
console.log("app got " + la.length);
console.timeEnd("bench app");
}
// ================= Java code for ListFolder ===================
private String ListFolder(Bundle b) throws Exception {
Log.d(TAG, "Got ListFolder");
String dir = b.getString("p1");
File directory = new File(dir);
File[] files = directory.listFiles();
ArrayList<String> paths = new ArrayList();
for (File f : files) {
paths.add(f.getPath());
}
JSONArray jsonArray = new JSONArray(paths);
String s = jsonArray.toString();
return s;
}
// ================ Bench output ===============================
plug got 673
bench plug: 115.82275390625 ms
<cut irrelevant data>
app got 673
bench app: 10430.629150390625 ms
=> 90x faster despite the JSON.parse call.
Greetings
Pascal G.