Skip to content
Browse files

Add simple benchmark utility. Currently ~6k/sec to 'localhost', ~10k/…

…sec to 127.0.0.1.

Using lib/Net/Statsd.pm sending to 127.0.0.1:9
Benchmark: timing 10000 iterations of decrement, gauge, increment, timing_001, timing_100...
 decrement:  0 wallclock secs ( 0.67 usr +  0.24 sys =  0.91 CPU) @ 10989.01/s (n=10000)
     gauge:  1 wallclock secs ( 0.65 usr +  0.27 sys =  0.92 CPU) @ 10869.57/s (n=10000)
 increment:  1 wallclock secs ( 0.68 usr +  0.34 sys =  1.02 CPU) @ 9803.92/s (n=10000)
timing_001:  1 wallclock secs ( 0.65 usr +  0.26 sys =  0.91 CPU) @ 10989.01/s (n=10000)
timing_100:  1 wallclock secs ( 0.66 usr +  0.27 sys =  0.93 CPU) @ 10752.69/s (n=10000)

Press ENTER or type command to continue
Using lib/Net/Statsd.pm sending to localhost:9
Benchmark: timing 10000 iterations of decrement, gauge, increment, timing_001, timing_100...
 decrement:  3 wallclock secs ( 1.03 usr +  0.63 sys =  1.66 CPU) @ 6024.10/s (n=10000)
     gauge:  2 wallclock secs ( 0.99 usr +  0.62 sys =  1.61 CPU) @ 6211.18/s (n=10000)
 increment:  3 wallclock secs ( 1.02 usr +  0.63 sys =  1.65 CPU) @ 6060.61/s (n=10000)
timing_001:  2 wallclock secs ( 1.00 usr +  0.62 sys =  1.62 CPU) @ 6172.84/s (n=10000)
timing_100:  3 wallclock secs ( 1.00 usr +  0.62 sys =  1.62 CPU) @ 6172.84/s (n=10000)
  • Loading branch information...
1 parent 4439cca commit a7c2801db31c9e8ef00c74a7fe08f2423b3be6f5 @timbunce timbunce committed
Showing with 35 additions and 0 deletions.
  1. +35 −0 benchmark.pl
View
35 benchmark.pl
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+=head1 NAME
+
+benchmark.pl - report max send rate
+
+=head1 DESCRIPTION
+
+A basic test of the time is takes to send stats.
+
+=cut
+
+use strict;
+use warnings;
+
+use Net::Statsd;
+use Benchmark;
+use Getopt::Long;
+
+GetOptions(
+ 'host|h=s' => \($Net::Statsd::HOST = 'localhost'),
+ 'port|p=i' => \($Net::Statsd::PORT = 9), # port 9 is the standard discard service
+) or exit 1;
+
+my $count = shift || 10_000;
+
+print "Using $INC{'Net/Statsd.pm'} sending to $Net::Statsd::HOST:$Net::Statsd::PORT\n";
+
+timethese($count, {
+ increment => sub { Net::Statsd::increment('foo.bar.i') },
+ decrement => sub { Net::Statsd::increment('foo.bar.d') },
+ timing_100 => sub { Net::Statsd::timing('foo.bar.t', 1) },
+ timing_001 => sub { Net::Statsd::timing('foo.bar.t', 0.1) },
+ gauge => sub { Net::Statsd::gauge('foo.bar.g', 42) },
+});

0 comments on commit a7c2801

Please sign in to comment.
Something went wrong with that request. Please try again.