forked from MeetMe/VorpalBunny
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtimetest.php
51 lines (44 loc) · 904 Bytes
/
timetest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* Timed Test
*
* Usage:
* php timetest.php [host [qty]]
*
* @package VorpalBunny
* @author Gavin M. Roy <gmr@myyearbook.com>
*/
require_once( "vorpalbunny.php" );
// Allow a command line override of localhost
if ( count( $argv ) > 1 )
{
$broker = $argv[1];
}
else
{
$broker = 'localhost';
}
// Allow a command line override the quantity
if ( count( $argv ) >= 3 )
{
$quantity = $argv[2];
}
else
{
$quantity = 1000;
}
// Create our VorpalBunny object
$vb = new VorpalBunny( $broker );
// Start time
$start = microtime( true );
// Send the messages
for ( $x = 0; $x < $quantity; $x++ )
{
// Publish to our rabbitmq broker
if ( ! $vb->publish( "", "test", "Hello World #" . $x ) )
{
print "Error publishing, exiting.\n";
break;
}
}
print number_format( $quantity, 0 ) . " messages sent in " . number_format( microtime( true ) - $start, 2 ) . " seconds\n";