blob: 1396eeacc3048e15485838300eb7ff50aa851e29 [file] [log] [blame]
Varun Gudisenacc9de9b2017-08-30 20:49:32 -05001/*******************************************************************************
2 * ============LICENSE_START=======================================================
3 * org.onap.dmaap
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END=========================================================
18 *
19 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
20 *
21 *******************************************************************************/
22
23#include <stdio.h>
24#include <ctime>
25#include <string.h>
26#include "cambria.h"
27
28const char* kAlarm =
29 "<EVENT>"
30 "<AGENT_ADDR>12.123.70.213</AGENT_ADDR>"
31 "<AGENT_RESOLVED>ptdor306me1.els-an.att.net</AGENT_RESOLVED>"
32 "<TIME_RECEIVED>1364716208</TIME_RECEIVED>"
33 " <PROTOCOL_VERSION>V1</PROTOCOL_VERSION>"
34 " <ENTERPRISE_LEN>9</ENTERPRISE_LEN>"
35 " <ENTERPRISE>.1.3.6.1.4.1.9.9.187</ENTERPRISE>"
36 " <GENERIC>6</GENERIC>"
37 " <SPECIFIC>2</SPECIFIC>"
38 " <COMMAND>167</COMMAND>"
39 " <REQUEST_ID>0</REQUEST_ID>"
40 " <ERROR_STATUS>0</ERROR_STATUS>"
41 " <ERROR_INDEX>0</ERROR_INDEX>"
42 " <AGENT_TIME_UP>1554393204</AGENT_TIME_UP>"
43 " <COMMUNITY_LEN>10</COMMUNITY_LEN>"
44 " <COMMUNITY>nidVeskaf0</COMMUNITY>"
45 " <VARBIND>"
46 " <VARBIND_OID>.1.3.6.1.2.1.15.3.1.14.32.4.52.58</VARBIND_OID>"
47 " <VARBIND_TYPE>OCTET_STRING_HEX</VARBIND_TYPE>"
48 " <VARBIND_VALUE>02 02 </VARBIND_VALUE>"
49 " </VARBIND>"
50 " <VARBIND>"
51 " <VARBIND_OID>.1.3.6.1.2.1.15.3.1.2.32.4.52.58</VARBIND_OID>"
52 " <VARBIND_TYPE>INTEGER</VARBIND_TYPE>"
53 " <VARBIND_VALUE>1</VARBIND_VALUE>"
54 " </VARBIND>"
55 " <VARBIND>"
56 " <VARBIND_OID>.1.3.6.1.4.1.9.9.187.1.2.1.1.7.32.4.52.58</VARBIND_OID>"
57 " <VARBIND_TYPE>OCTET_STRING_ASCII</VARBIND_TYPE>"
58 " <VARBIND_VALUE>peer in wrong AS</VARBIND_VALUE>"
59 " </VARBIND>"
60 " <VARBIND>"
61 " <VARBIND_OID>.1.3.6.1.4.1.9.9.187.1.2.1.1.8.32.4.52.58</VARBIND_OID>"
62 " <VARBIND_TYPE>INTEGER</VARBIND_TYPE>"
63 " <VARBIND_VALUE>4</VARBIND_VALUE>"
64 " </VARBIND>"
65 "</EVENT>";
66
67int main ( int argc, const char* argv[] )
68{
69 char** msgs = new char* [ 100 ];
70 for ( int i=0; i<100; i++ )
71 {
72 msgs[i] = new char [ ::strlen ( kAlarm + 1 ) ];
73 ::strcpy ( msgs[i], kAlarm );
74 }
75
76 std::time_t start = std::time ( NULL );
77 for ( int i=0; i<5000; i++ )
78 {
79 ::cambriaSimpleSendMultiple ( "localhost", 8080, "topic", "streamName", (const char**)msgs, 100 );
80 if ( i % 50 == 0 )
81 {
82 std::time_t end = std::time ( NULL );
83 double seconds = difftime ( end, start );
84 ::printf ( "%.f seconds for %u posts.\n", seconds, i*100 );
85 }
86 }
87 std::time_t end = std::time ( NULL );
88 double seconds = difftime ( end, start );
89 ::printf ( "%.f seconds for 1,000,000 posts.\n", seconds );
90
91 return 0;
92}