403Webshell
Server IP : 66.29.132.122  /  Your IP : 3.141.197.251
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/proc/self/root/proc/thread-self/root/opt/alt/alt-nodejs8/root/lib/node_modules/npm/node_modules.bundled/lockfile/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/proc/self/root/proc/thread-self/root/opt/alt/alt-nodejs8/root/lib/node_modules/npm/node_modules.bundled/lockfile/speedtest.js
const path = require('path');
const async = require('async');
const lf = require('lockfile');
const fs = require('fs');

const n = +process.argv[3] || 300;
const a = Array.apply(null, {length: n}).map(function(_, i) {
  return i
})
const file = path.resolve(__dirname, 'speed-test.lock');

try{
    fs.unlinkSync(file);
}
catch(e){}


/// NOTE: this should run in about 30ms on a SSD Ubuntu 16.04, that is fast, because we are locking/unlocking 300 locks
/// *HOWEVER* if we change async.eachSeries to async.each, lockfile will barf immediately, and I can't get lockfile
/// to not barf, using any of the options {} available to lockfile#lock.


const parallel = process.argv[2] === 'parallel';

var fn, msg;

if(parallel){
    msg = 'parallel';
    fn = async.each;
}
else{
    msg = 'series';
    fn = async.eachSeries;
}


const start = Date.now();
console.log(' => locking/unlocking ' + a.length + ' times, in ' + msg);

fn(a, function (val, cb) {

    console.log('try %d', val)

    lf.lock(file, { retries: n * 3 }, function (err) {
        if (err) {
            cb(err);
        }
        else {
            console.log('complete %d', val)
            lf.unlock(file, cb);
        }
    });

}, function complete(err) {

    if (err) {
        throw err;
    }

    console.log(' => Time required for lockfile => ', Date.now() - start, 'ms');
    process.exit(0);

});

Youez - 2016 - github.com/yon3zu
LinuXploit