Files: d2f2697f296dd39aed6a8b63c6d04a736a7db5b3 / node_modules / pull-file / examples / node-rate.js
477 bytesRaw
1 | |
2 | |
3 | var fs = require('fs') |
4 | |
5 | module.exports = function (file, cb) { |
6 | var start = Date.now(), total = 0 |
7 | fs.createReadStream(file) |
8 | .on('data', function (b) { |
9 | total += b.length |
10 | }) |
11 | .on('end', function () { |
12 | cb(null, {time: Date.now() - start, total: total}) |
13 | }) |
14 | } |
15 | |
16 | if(!module.parent) |
17 | module.exports (process.argv[2], function (err, stats) { |
18 | var seconds = stats.time/1000, mb = stats.total/(1024*1024) |
19 | console.log(seconds, mb, mb/seconds) |
20 | }) |
21 | |
22 | |
23 |
Built with git-ssb-web