File: Objects_iterator.cpp

package info (click to toggle)
atlas-cpp 0.5.98-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,652 kB
  • ctags: 2,284
  • sloc: sh: 8,305; cpp: 6,372; python: 1,471; makefile: 216
file content (81 lines) | stat: -rw-r--r-- 2,644 bytes parent folder | download | duplicates (8)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "timer.h"

#include <Atlas/Objects/RootOperation.h>

#include <iostream>

int main(int argc, char ** argv)
{
    Atlas::Objects::Operation::RootOperation op;
    Atlas::Message::MapType message;

    TIME_ON;
    int i;
    for (i = 0; i < 1000000; ++i) {
        Atlas::Message::MapType message;
        op->addToMessage(message);
        if (i == 0) {
            std::cout << "Message: " << message.size() << std::endl << std::flush;
        }
        Atlas::Message::MapType::const_iterator I = message.begin();
        Atlas::Message::MapType::const_iterator Iend = message.end();
        for (; I != Iend; ++I) {
            std::string key = I->first;
            Atlas::Message::Element val = I->second;
        }
    }
    TIME_OFF("Empty Object to Message conversion and iteration");

    TIME_ON;
    for (i = 0; i < 1000000; ++i) {
        Atlas::Objects::Operation::RootOperation::const_iterator I = op->begin();
        Atlas::Objects::Operation::RootOperation::const_iterator Iend = op->end();
        for (; I != Iend; ++I) {
            std::string key = I->first;
            Atlas::Message::Element val = I->second;
        }
    }
    TIME_OFF("Empty Object iteration");

    // Fill the object with non-default values
    op->setId("foo");
    op->setParents(std::list<std::string>(1, "bar"));
    op->setStamp(23.42);
    op->setObjtype("non_standard");
    op->setName("fred");
    op->setSerialno(17);
    op->setRefno(23);
    op->setFrom("jim");
    op->setTo("bob");
    op->setSeconds(10800);
    op->setFutureSeconds(1);
    op->setArgs(std::vector<Atlas::Objects::Root>(1, Atlas::Objects::Operation::RootOperation()));

    TIME_ON;
    for (i = 0; i < 1000000; ++i) {
        Atlas::Message::MapType message;
        op->addToMessage(message);
        if (i == 0) {
            std::cout << "Message: " << message.size() << std::endl << std::flush;
        }
        Atlas::Message::MapType::const_iterator I = message.begin();
        Atlas::Message::MapType::const_iterator Iend = message.end();
        for (; I != Iend; ++I) {
            std::string key = I->first;
            Atlas::Message::Element val = I->second;
        }
    }
    TIME_OFF("Full Object to Message conversion and iteration");


    TIME_ON;
    for (i = 0; i < 1000000; ++i) {
        Atlas::Objects::Operation::RootOperation::const_iterator I = op->begin();
        Atlas::Objects::Operation::RootOperation::const_iterator Iend = op->end();
        for (; I != Iend; ++I) {
            std::string key = I->first;
            Atlas::Message::Element val = I->second;
        }
    }
    TIME_OFF("Full Object iteration");
}