~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to plugin/innodb_memcached/daemon_memcached/devtools/bench_noreply.pl

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/perl
 
2
#
 
3
use warnings;
 
4
use strict;
 
5
 
 
6
use IO::Socket::INET;
 
7
 
 
8
use FindBin;
 
9
 
 
10
@ARGV == 1 or @ARGV == 2
 
11
    or die "Usage: $FindBin::Script HOST:PORT [COUNT]\n";
 
12
 
 
13
# Note that it's better to run the test over the wire, because for
 
14
# localhost the task may become CPU bound.
 
15
my $addr = $ARGV[0];
 
16
my $count = $ARGV[1] || 10_000;
 
17
 
 
18
my $sock = IO::Socket::INET->new(PeerAddr => $addr,
 
19
                                 Timeout  => 3);
 
20
die "$!\n" unless $sock;
 
21
 
 
22
 
 
23
# By running 'noreply' test first we also ensure there are no reply
 
24
# packets left in the network.
 
25
foreach my $noreply (1, 0) {
 
26
    use Time::HiRes qw(gettimeofday tv_interval);
 
27
 
 
28
    print "'noreply' is ", $noreply ? "enabled" : "disabled", ":\n";
 
29
    my $param = $noreply ? 'noreply' : '';
 
30
    my $start = [gettimeofday];
 
31
    foreach (1 .. $count) {
 
32
        print $sock "add foo 0 0 1 $param\r\n1\r\n";
 
33
        scalar<$sock> unless $noreply;
 
34
        print $sock "set foo 0 0 1 $param\r\n1\r\n";
 
35
        scalar<$sock> unless $noreply;
 
36
        print $sock "replace foo 0 0 1 $param\r\n1\r\n";
 
37
        scalar<$sock> unless $noreply;
 
38
        print $sock "append foo 0 0 1 $param\r\n1\r\n";
 
39
        scalar<$sock> unless $noreply;
 
40
        print $sock "prepend foo 0 0 1 $param\r\n1\r\n";
 
41
        scalar<$sock> unless $noreply;
 
42
        print $sock "incr foo 1 $param\r\n";
 
43
        scalar<$sock> unless $noreply;
 
44
        print $sock "decr foo 1 $param\r\n";
 
45
        scalar<$sock> unless $noreply;
 
46
        print $sock "delete foo $param\r\n";
 
47
        scalar<$sock> unless $noreply;
 
48
    }
 
49
    my $end = [gettimeofday];
 
50
    printf("update commands: %.2f secs\n\n", tv_interval($start, $end));
 
51
}