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