Skip to content

Commit

Permalink
generate and log basic system stats each time metadata is read or sto…
Browse files Browse the repository at this point in the history
…red to disk
  • Loading branch information
Jason J. Gullickson committed Jan 3, 2015
1 parent 689aa1c commit 19f6642
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions jsfs2.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ function save_metadata(){
log.message(log.INFO, "metadata saved to disk");
}
});

var stats = system_stats();
log.message(log.INFO, stats.file_count + " files stored in " + stats.block_count + " blocks");
}

function load_metadata(){
Expand All @@ -43,6 +46,28 @@ function load_metadata(){
} catch(ex) {
log.message(log.WARN, "unable to load metadata from disk: " + ex);
}

var stats = system_stats();
log.message(log.INFO, stats.file_count + " files stored in " + stats.block_count + " blocks");
}

function system_stats(){

var stats = {};
stats.file_count = 0;
stats.block_count = 0;

for(var file in stored_files){
if(stored_files.hasOwnProperty(file)){
// count blocks
stats.block_count = stats.block_count + stored_files[file].blocks.length;

// increment file count
stats.file_count++;
}
}

return stats;
}

// simple encrypt-decrypt functions
Expand Down

0 comments on commit 19f6642

Please sign in to comment.