Add simple EventCollector benchmark
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Mon, 30 Jul 2007 14:22:12 +0100
changeset 1727 064aaa84c103
parent 1726 1aece815a3ba
child 1728 190372a33951
Add simple EventCollector benchmark
utils/bench-event-collector.cc
utils/wscript
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/utils/bench-event-collector.cc	Mon Jul 30 14:22:12 2007 +0100
@@ -0,0 +1,35 @@
+#include <iostream>
+#include <vector>
+#include <stdlib.h>
+#include "ns3/event-collector.h"
+#include "ns3/simulator.h"
+
+using namespace ns3;
+
+void Foo ()
+{
+
+}
+
+int main (int argc, char *argv[])
+{
+    EventCollector events;
+
+    if (argc < 3)
+    {
+        std::cerr << "usage: bench-event-collector NUM_EVENTS NUM_REPETITIONS" << std::endl;
+        return 1;
+    }
+    int numEvents = atoi (argv[1]);
+    int numRepetitions = atoi (argv[2]);
+    
+    for (int repetition = 0; repetition < numRepetitions; ++repetition)
+    {
+        for (int n = 0; n < numEvents; ++n)
+        {
+            events.Track (Simulator::Schedule (Simulator::Now (), Foo));
+        }
+        Simulator::Run ();
+    }
+}
+
--- a/utils/wscript	Mon Jul 30 13:09:02 2007 +0100
+++ b/utils/wscript	Mon Jul 30 14:22:12 2007 +0100
@@ -21,3 +21,6 @@
 
     obj = create_ns_prog('replay-simulation', 'replay-simulation.cc')
     obj.uselib_local = "ns3-core ns3-common ns3-simulator"
+
+    obj = create_ns_prog('bench-event-collector', 'bench-event-collector.cc')
+    obj.uselib_local = "ns3-simulator"