|
|
| 33 |
|
33 |
|
| 34 |
std::string g_me; |
34 |
std::string g_me; |
| 35 |
#define LOG(x) std::cout << x << std::endl |
35 |
#define LOG(x) std::cout << x << std::endl |
| 36 |
#define LOGME(x) LOG (g_me << x) |
36 |
#define LOGME(x) LOG (g_me << x) |
| 37 |
#define DEB(x) if (g_debug) { LOGME (x) ; } |
37 |
#define DEB(x) if (g_debug) { LOGME (x); } |
| 38 |
|
38 |
|
| 39 |
// Output field width |
39 |
// Output field width |
| 40 |
int g_fwidth = 6; |
40 |
int g_fwidth = 6; |
|
|
| 43 |
{ |
43 |
{ |
| 44 |
public: |
44 |
public: |
| 45 |
Bench (const uint32_t population, const uint32_t total) |
45 |
Bench (const uint32_t population, const uint32_t total) |
| 46 |
: m_population (population), |
46 |
: m_population (population), |
| 47 |
m_total (total), |
47 |
m_total (total), |
| 48 |
m_count (0) |
48 |
m_count (0) |
| 49 |
{ }; |
49 |
{ }; |
| 50 |
|
50 |
|
| 51 |
void SetRandomStream (Ptr<RandomVariableStream> stream) |
51 |
void SetRandomStream (Ptr<RandomVariableStream> stream) |
| 52 |
{ |
52 |
{ |
| 53 |
m_rand = stream; |
53 |
m_rand = stream; |
| 54 |
} |
54 |
} |
| 55 |
|
55 |
|
| 56 |
void SetPopulation (const uint32_t population) |
56 |
void SetPopulation (const uint32_t population) |
| 57 |
{ |
57 |
{ |
| 58 |
m_population = population; |
58 |
m_population = population; |
| 59 |
} |
59 |
} |
| 60 |
|
60 |
|
| 61 |
void SetTotal (const uint32_t total) |
61 |
void SetTotal (const uint32_t total) |
| 62 |
{ |
62 |
{ |
| 63 |
m_total = total; |
63 |
m_total = total; |
| 64 |
} |
64 |
} |
| 65 |
|
65 |
|
| 66 |
void RunBench (void); |
66 |
void RunBench (void); |
| 67 |
private: |
67 |
private: |
| 68 |
void Cb (void); |
68 |
void Cb (void); |
| 69 |
|
69 |
|
| 70 |
Ptr<RandomVariableStream> m_rand; |
70 |
Ptr<RandomVariableStream> m_rand; |
| 71 |
uint32_t m_population; |
71 |
uint32_t m_population; |
| 72 |
uint32_t m_total; |
72 |
uint32_t m_total; |
|
Lines 128-134
Ptr<RandomVariableStream>
|
Link Here
|
|---|
|
| 128 |
GetRandomStream (std::string filename) |
128 |
GetRandomStream (std::string filename) |
| 129 |
{ |
129 |
{ |
| 130 |
Ptr<RandomVariableStream> stream = 0; |
130 |
Ptr<RandomVariableStream> stream = 0; |
| 131 |
|
131 |
|
| 132 |
if (filename == "") |
132 |
if (filename == "") |
| 133 |
{ |
133 |
{ |
| 134 |
LOGME ("using default exponential distribution"); |
134 |
LOGME ("using default exponential distribution"); |
|
Lines 153-159
GetRandomStream (std::string filename)
|
Link Here
|
|---|
|
| 153 |
|
153 |
|
| 154 |
double value; |
154 |
double value; |
| 155 |
std::vector<double> nsValues; |
155 |
std::vector<double> nsValues; |
| 156 |
|
156 |
|
| 157 |
while (!input->eof ()) |
157 |
while (!input->eof ()) |
| 158 |
{ |
158 |
{ |
| 159 |
if (*input >> value) |
159 |
if (*input >> value) |
|
Lines 173-179
GetRandomStream (std::string filename)
|
Link Here
|
|---|
|
| 173 |
drv->SetValueArray (&nsValues[0], nsValues.size ()); |
173 |
drv->SetValueArray (&nsValues[0], nsValues.size ()); |
| 174 |
stream = drv; |
174 |
stream = drv; |
| 175 |
} |
175 |
} |
| 176 |
|
176 |
|
| 177 |
return stream; |
177 |
return stream; |
| 178 |
} |
178 |
} |
| 179 |
|
179 |
|
|
Lines 191-197
int main (int argc, char *argv[])
|
Link Here
|
|---|
|
| 191 |
uint32_t total = 1000000; |
191 |
uint32_t total = 1000000; |
| 192 |
uint32_t runs = 1; |
192 |
uint32_t runs = 1; |
| 193 |
std::string filename = ""; |
193 |
std::string filename = ""; |
| 194 |
|
194 |
|
| 195 |
CommandLine cmd; |
195 |
CommandLine cmd; |
| 196 |
cmd.Usage ("Benchmark the simulator scheduler.\n" |
196 |
cmd.Usage ("Benchmark the simulator scheduler.\n" |
| 197 |
"\n" |
197 |
"\n" |
|
Lines 218-224
int main (int argc, char *argv[])
|
Link Here
|
|---|
|
| 218 |
ObjectFactory factory ("ns3::MapScheduler"); |
218 |
ObjectFactory factory ("ns3::MapScheduler"); |
| 219 |
if (schedCal) { factory.SetTypeId ("ns3::CalendarScheduler"); } |
219 |
if (schedCal) { factory.SetTypeId ("ns3::CalendarScheduler"); } |
| 220 |
if (schedHeap) { factory.SetTypeId ("ns3::HeapScheduler"); } |
220 |
if (schedHeap) { factory.SetTypeId ("ns3::HeapScheduler"); } |
| 221 |
if (schedList) { factory.SetTypeId ("ns3::ListScheduler"); } |
221 |
if (schedList) { factory.SetTypeId ("ns3::ListScheduler"); } |
| 222 |
Simulator::SetScheduler (factory); |
222 |
Simulator::SetScheduler (factory); |
| 223 |
|
223 |
|
| 224 |
LOGME (std::setprecision (g_fwidth - 6)); |
224 |
LOGME (std::setprecision (g_fwidth - 6)); |
|
Lines 228-234
int main (int argc, char *argv[])
|
Link Here
|
|---|
|
| 228 |
LOGME ("population: " << pop); |
228 |
LOGME ("population: " << pop); |
| 229 |
LOGME ("total events: " << total); |
229 |
LOGME ("total events: " << total); |
| 230 |
LOGME ("runs: " << runs); |
230 |
LOGME ("runs: " << runs); |
| 231 |
|
231 |
|
| 232 |
Bench *bench = new Bench (pop, total); |
232 |
Bench *bench = new Bench (pop, total); |
| 233 |
bench->SetRandomStream (GetRandomStream (filename)); |
233 |
bench->SetRandomStream (GetRandomStream (filename)); |
| 234 |
|
234 |
|
|
Lines 246-260
int main (int argc, char *argv[])
|
Link Here
|
|---|
|
| 246 |
std::left << std::setw (g_fwidth) << "Per (s/ev)" ); |
246 |
std::left << std::setw (g_fwidth) << "Per (s/ev)" ); |
| 247 |
LOG (std::setfill ('-') << |
247 |
LOG (std::setfill ('-') << |
| 248 |
std::right << std::setw (g_fwidth) << " " << |
248 |
std::right << std::setw (g_fwidth) << " " << |
| 249 |
std::right << std::setw (g_fwidth) << " " << |
249 |
std::right << std::setw (g_fwidth) << " " << |
| 250 |
std::right << std::setw (g_fwidth) << " " << |
250 |
std::right << std::setw (g_fwidth) << " " << |
| 251 |
std::right << std::setw (g_fwidth) << " " << |
251 |
std::right << std::setw (g_fwidth) << " " << |
| 252 |
std::right << std::setw (g_fwidth) << " " << |
252 |
std::right << std::setw (g_fwidth) << " " << |
| 253 |
std::right << std::setw (g_fwidth) << " " << |
253 |
std::right << std::setw (g_fwidth) << " " << |
| 254 |
std::right << std::setw (g_fwidth) << " " << |
254 |
std::right << std::setw (g_fwidth) << " " << |
| 255 |
std::setfill (' ') |
255 |
std::setfill (' ') |
| 256 |
); |
256 |
); |
| 257 |
|
257 |
|
| 258 |
// prime |
258 |
// prime |
| 259 |
DEB ("priming"); |
259 |
DEB ("priming"); |
| 260 |
std::cout << std::left << std::setw (g_fwidth) << "(prime)"; |
260 |
std::cout << std::left << std::setw (g_fwidth) << "(prime)"; |
|
Lines 265-271
int main (int argc, char *argv[])
|
Link Here
|
|---|
|
| 265 |
for (uint32_t i = 0; i < runs; i++) |
265 |
for (uint32_t i = 0; i < runs; i++) |
| 266 |
{ |
266 |
{ |
| 267 |
std::cout << std::setw (g_fwidth) << i; |
267 |
std::cout << std::setw (g_fwidth) << i; |
| 268 |
|
268 |
|
| 269 |
bench->RunBench (); |
269 |
bench->RunBench (); |
| 270 |
} |
270 |
} |
| 271 |
|
271 |
|