[openamq-dev] timing
Nick Levine
ndl at ravenbrook.com
Thu Aug 23 15:48:50 CEST 2007
I have concerns about the time taken to publish content.
I took the message-posting code which Mousami posted earlier today
http://lists.openamq.org/pipermail/openamq-dev/2007-August/000220.html
and made minor changes to it (see below), so that in particular it
posts a fixed number (10k) of messages. The exchange is already
declared "direct", there's one queue already bound to
"my-routing-key".
On the machine whose stats I posted yesterday
http://lists.openamq.org/pipermail/openamq-dev/2007-August/000215.hmtl
this loop takes about ten seconds to run. (I cranked the loop size
down just to check that setup and teardown times aren't dominating the
runtime.)
So: about one thousand messages posted per second. Is this reasonable?
Is it slower than it might be otherwise because I built the libraries
as "debug" rather than "release"?
By the way, the time taken to retrieve these 10k messages is about 0.1
seconds, which is more what I would have expected (100k messages
retrieved per second).
Many thanks, as always,
- nick
-----------
#include <asl.h>
#include <amq_client_connection.h>
#include <amq_client_session.h>
int main(int argc, char** argv)
{
int i, res;
amq_client_connection_t *connection = NULL; //Current Client
amq_client_session_t *session = NULL; // current session
amq_content_basic_t *content = NULL; // Message content
icl_longstr_t *auth_data;//Initialize iCL System
icl_system_initialise(argc, argv);//Open session to local server
auth_data = amq_client_connection_auth_plain("guest","guest");
connection = amq_client_connection_new("localhost", "/",
auth_data,"test", 0, 30000);
icl_longstr_destroy(&auth_data);
if(!connection)
{
icl_console_print("E: could not open connection");
return(1);
}
session = amq_client_session_new(connection);
if(!session)
{
icl_console_print("E: could not open session");
return(1);
}
for(i = 0; i< 10000; i++)
{
/* Create a conent and send it to queue exchange */
content = amq_content_basic_new();
amq_content_basic_set_body(content, "HELLO", 10 , NULL);
amq_content_basic_set_message_id(content, "ID001");
res=amq_client_session_basic_publish(
session,
content,
0,
"my-exchange",
"my-routing-key",
0,
0);
amq_content_basic_unlink(&content);
}
//Shut down connection and session
amq_client_session_destroy(&session);
amq_client_connection_destroy(&connection);
//Terminate iCL system
icl_system_terminate();
return 0;
}
More information about the openamq-dev
mailing list