43 printf(
"usage: %s <content-size-in-byte> <epochs>\n", argv[0]);
44 printf(
"output will be: <encoding> <content-size in byte> <encoded-msg-size in bytes > <overhead-percent> <encoding-time in ms/msg> <decoding-time in ms/msg> <epochs>\n");
50 uint32_t BUFFER_MAX = atoi(argv[1]);
51 int32_t epochs = atoi(argv[2]);
58 msg.setSender(origin);
59 msg.addReceiver(receiver);
60 msg.addReplyTo(origin);
62 msg.setProtocol(std::string(
"RIMRES"));
63 msg.setLanguage(std::string(
"test language"));
64 msg.setEncoding(std::string(
"test encoding"));
65 msg.setOntology(std::string(
"test ontology"));
66 msg.setReplyWith(std::string(
"test reply_with"));
67 base::Time time = base::Time::fromString(
"20101223-12:00:37:980", base::Time::Milliseconds);
69 msg.setConversationID(std::string(
"test conversationID"));
75 info += origin.getName();
76 info += receiver.getName();
77 info += origin.getName();
78 info += msg.getLanguage();
79 info += msg.getEncoding();
80 info += msg.getOntology();
81 info += msg.getReplyWith();
83 info += msg.getConversationID();
87 char* buffer = (
char*) calloc(1,BUFFER_MAX+1);
90 fprintf(stderr,
"Allocation of memory for test message failed\n");
94 for(
size_t i = 0; i < BUFFER_MAX; ++i)
96 buffer[i] = (char) 48 + rand() % 40;
100 buffer[BUFFER_MAX] =
'\0';
101 std::string content(buffer, BUFFER_MAX);
102 msg.setContent(content);
104 uint32_t payloadsize = info.size() + BUFFER_MAX + 8 + 1;
105 printf(
"# PAYLOAD SIZE: %d\n", payloadsize);
106 printf(
"# CONTENT SIZE: %lu\n", content.size());
107 printf(
"# MSG CONTENT SIZE: %lu\n", msg.getContent().size());
112 std::string encodedMsg;
113 printf(
"#<encoding> <content-size in byte> <encoded-msg-size in bytes > <overhead-percent> <encoding-time in ms/msg> <decoding-time in ms/msg> <epochs>\n");
116 numeric::Stats<double> msgEncodingStats;
117 numeric::Stats<double> msgDecodingStats;
119 numeric::Stats<double> envEncodingStats;
120 numeric::Stats<double> envDecodingStats;
124 struct timeval start, stop, diff;
125 for(
int i = 0; i < epochs; ++i)
127 gettimeofday(&start, 0);
129 gettimeofday(&stop, 0);
131 double totaltime = diff.tv_sec*1000 + diff.tv_usec/1000.0;
132 msgEncodingStats.update(totaltime);
137 struct timeval start, stop, diff;
138 for(
int i = 0; i < epochs; ++i)
140 gettimeofday(&start, 0);
141 if(!inputParser.parseData(encodedMsg, msg, representationType))
145 gettimeofday(&stop, 0);
147 double totaltime = diff.tv_sec*1000 + diff.tv_usec/1000.0;
148 msgDecodingStats.update(totaltime);
152 double overheadInPercent = (encodedMsg.size() - payloadsize)*1.0/(1.0*encodedMsg.size());
154 printf(
"message %d %d %10.6f %10.6f %10.6f %10.6f %10.6f %d %s\n", BUFFER_MAX, (
int) encodedMsg.size(), overheadInPercent, msgEncodingStats.mean(), msgEncodingStats.stdev(), msgDecodingStats.mean(), msgDecodingStats.stdev(), epochs,
representation::TypeTxt[representationType].c_str());
158 std::string encodedEnvelope;
168 for(
int i = 0; i < epochs; ++i)
172 struct timeval start, stop, diff;
173 gettimeofday(&start, 0);
176 gettimeofday(&stop, 0);
179 double totaltime = diff.tv_sec*1000 + diff.tv_usec/1000.0;
180 envEncodingStats.update(totaltime);
185 struct timeval start, stop, diff;
186 gettimeofday(&start, 0);
192 gettimeofday(&stop, 0);
195 double totaltime = diff.tv_sec*1000 + diff.tv_usec/1000.0;
196 envDecodingStats.update(totaltime);
200 overheadInPercent = (encodedEnvelope.size() - encodedMsg.size())/(1.0*encodedEnvelope.size());
201 printf(
"envelope %d %d %10.6f %10.6f %10.6f %10.6f %10.6f %d %s %s\n", BUFFER_MAX, (
int) encodedEnvelope.size(), overheadInPercent, envEncodingStats.mean(), envEncodingStats.stdev(), envDecodingStats.mean(), envDecodingStats.stdev(), epochs,
representation::TypeTxt[envRepresentationType].c_str(),
representation::TypeTxt[representationType].c_str());
static std::string create(const ACLEnvelope &msg, const representation::Type &acl_representation)
ACLMessage envelope (also typed as fipa::acl::Letter) includes the base envelope and updated fields...
static std::string create(const ACLMessage &msg, const representation::Type &acl_representation)
static bool parseData(const std::string &storage, ACLEnvelope &envelope, representation::Type type=fipa::acl::representation::BITEFFICIENT)
Allows to parse a bytestream that conforms to the bitefficient representation of FIPA messages to a A...
const std::string TypeTxt[]
This class provides a representation of a message conforming to the FIPA specification SC00061...
int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
Implements the general AgentID functionality, which is present throughout the fipa specifications(FIP...
Agent Communication Language.