benchmark.cc
1 |
/* Copyright (C) 2012 Jan Moringen
|
---|---|
2 |
*
|
3 |
* This Program is free software: you can redistribute it and/or modify
|
4 |
* it under the terms of the GNU General Public License as published by
|
5 |
* the Free Software Foundation, either version 3 of the License, or
|
6 |
* (at your option) any later version.
|
7 |
*
|
8 |
* This Program is distributed in the hope that it will be useful,
|
9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11 |
* GNU General Public License for more details.
|
12 |
*
|
13 |
* You should have received a copy of the GNU General Public License
|
14 |
* along with this program. If not, see <http://www.gnu.org/licenses>.
|
15 |
*/
|
16 |
|
17 |
#include <stdlib.h> |
18 |
|
19 |
#include <string> |
20 |
|
21 |
#include <rsb/protocol/EventId.pb.h> |
22 |
#include <rsb/protocol/EventMetaData.pb.h> |
23 |
#include <rsb/protocol/Notification.pb.h> |
24 |
|
25 |
int main(int argc, char* argv[]) { |
26 |
|
27 |
unsigned char buffer[100]; |
28 |
for (unsigned int i = 0; i != 1000000; ++i) { |
29 |
{ |
30 |
rsb::protocol::Notification n; |
31 |
n.set_scope("foo");
|
32 |
n.set_method("bar");
|
33 |
n.set_wire_schema("baz");
|
34 |
n.set_data("fez");
|
35 |
|
36 |
rsb::protocol::EventId* e = n.mutable_event_id(); |
37 |
e->set_sender_id("foo");
|
38 |
e->set_sequence_number(0);
|
39 |
|
40 |
rsb::protocol::EventMetaData* m = n.mutable_meta_data(); |
41 |
m->set_create_time(0);
|
42 |
m->set_send_time(0);
|
43 |
|
44 |
n.SerializeToArray(buffer, 100);
|
45 |
} |
46 |
{ |
47 |
rsb::protocol::Notification n; |
48 |
n.ParseFromArray(buffer, 100);
|
49 |
} |
50 |
} |
51 |
|
52 |
return EXIT_SUCCESS;
|
53 |
} |