utils/bench-event-collector.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 21 Mar 2008 13:41:16 -0700
changeset 2693 56e28e34e109
parent 1727 064aaa84c103
permissions -rw-r--r--
TypeId::GetAttributeListN -> TypeId::GetAttributeN
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1727
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     1
#include <iostream>
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     2
#include <vector>
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     3
#include <stdlib.h>
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     4
#include "ns3/event-collector.h"
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     5
#include "ns3/simulator.h"
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     6
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     7
using namespace ns3;
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     8
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     9
void Foo ()
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    10
{
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    11
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    12
}
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    13
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    14
int main (int argc, char *argv[])
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    15
{
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    16
    EventCollector events;
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    17
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    18
    if (argc < 3)
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    19
    {
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    20
        std::cerr << "usage: bench-event-collector NUM_EVENTS NUM_REPETITIONS" << std::endl;
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    21
        return 1;
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    22
    }
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    23
    int numEvents = atoi (argv[1]);
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    24
    int numRepetitions = atoi (argv[2]);
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    25
    
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    26
    for (int repetition = 0; repetition < numRepetitions; ++repetition)
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    27
    {
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    28
        for (int n = 0; n < numEvents; ++n)
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    29
        {
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    30
            events.Track (Simulator::Schedule (Simulator::Now (), Foo));
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    31
        }
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    32
        Simulator::Run ();
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    33
    }
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    34
}
064aaa84c103 Add simple EventCollector benchmark
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    35