Uname: Linux webm016.cluster127.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 7.4.33 [ PHP INFO ] PHP os: Linux
Server Ip: 54.36.31.145
Your Ip: 216.73.216.182
User: homesquasz (91404) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : index.js
var bench = require('nanobench');
var fs = require('fs');
var path = require('path');
var through = require('through2');

bench('small file × 5', function (b) {
    warmup(run, function () {
        b.start();

        var i = 5;
        run(function next () {
            if (--i === 0) b.end();
            else run(next);
        });
    });

    function run (cb) {
        smallFile()
            .pipe(brfs())
            .on('data', function () {})
            .on('end', function () {
                cb();
            });
    }
});

bench('large file without fs', function (b) {
    warmup(run, function () {
        b.start();

        var i = 5;
        run(function next () {
            if (--i === 0) b.end();
            else run(next);
        });
    });

    function run (cb) {
        largeFile()
            .pipe(brfs())
            .on('data', function () {})
            .on('end', function () {
                b.end();
            });
    }
});

bench('large file with fs', function (b) {
    warmup(run, function () {
        b.start();

        var i = 5;
        run(function next () {
            if (--i === 0) b.end();
            else run(next);
        });
    });

    function run (cb) {
        largeFile()
            .pipe(withFS())
            .pipe(brfs())
            .on('data', function () {})
            .on('end', function () {
                b.end();
            });
    }
});

function brfs () {
    return require('../')({
        fs: {
            readFileSync: function (path) {
                return path;
            }
        }
    });
}

function smallFile () {
    var r = through();
    r.end('var a, fs = require("fs"), x; fs.readFileSync("index.js");');
    return r;
}
function largeFile () {
    return fs.createReadStream(path.join(__dirname, './input.js'));
}
function withFS () {
    return through(function (chunk, enc, next) {
        next(null, chunk);
    }, function (next) {
        this.push('\nvar a, fs = require("fs"), x; fs.readFileSync("index.js");');
        next();
    });
}

function warmup (run, cb) {
    var i = 5;
    run(function next () {
        if (--i === 0) cb();
        else run(next);
    });
}
© 2026 GrazzMean