Open natevw opened 9 years ago
Script updated for on-device testing too:
var fs = null,
data = Buffer(512*1024);
if (0) {
var vol = require("./img_volume.js").createDriverSync("/Users/natevw/Desktop/fat32.img"),
fs = require("./").createFileSystem(vol, {umask:0020, uid:99, gid:42});
writeData();
} else {
var sd = require('sdcard').use(require('tessel').port['A'], {getFilesystems:true}),
fs = null;
sd.on('ready', function(e, fss) {
if (e) throw e;
fs = fss[0];
writeData();
});
}
function writeData() {
setImmediate(function () {
var t1 = Date.now();
fs.writeFile("sample-"+t1+".bin", data, function (e) {
var t2 = Date.now();
console.log(t2 - t1);
writeData();
});
});
}
Couple notes:
Latest test script:
var fs = null,
data = Buffer(60*1024);
if (0) {
var vol = require("fatfs/img_volume.js").createDriverSync("/Users/natevw/Desktop/fat32.img"),
fs = require('fatfs').createFileSystem(vol, {umask:0020, uid:99, gid:42});
writeData();
} else {
var sd = require("./").use(require('tessel').port['A'], {getFilesystems:true}),
fs = null;
sd.on('ready', function (fss) {
fs = fss[0];
writeData();
});
}
function writeData() {
setImmediate(function () {
var t1 = Date.now();
//process.stdout.write("--> Writing "+t1+"…\t");
fs.writeFile("sample-"+t1+".bin", data, function (e) {
var t2 = Date.now();
console.log(t2 - t1);
writeData();
});
});
}
…gives results like this on a dirty card (i.e. already lots of existing files):
25544
22281
21707
22458
22115
23038
22843
22223
So at this point there's still AFAIK a weird temporary slowdown during the first couple dozen files, but it does seem to stabilize.
The output grows steadily, starting at around 330ms for the write and growing to 2004ms after less than 50 files: https://gist.github.com/natevw/41ac4cf4f3788d4193ed
Contrary to https://github.com/tessel/sdcard/issues/20, creating a new filesystem instance (or in this case: a whole new process!) does not keep the timings low.