# HG changeset patch # User Mathieu Lacage # Date 1179413103 -7200 # Node ID d845cfea2a164827a6e6fea5b98f1e6854e3f389 # Parent 956a76f5fd56e243ba483c091d52e94373748874 add benchmark by gustavo diff -r 956a76f5fd56 -r d845cfea2a16 SConstruct --- a/SConstruct Thu May 17 14:39:54 2007 +0200 +++ b/SConstruct Thu May 17 16:45:03 2007 +0200 @@ -340,6 +340,12 @@ run_tests.add_deps(['core', 'simulator', 'common']) run_tests.add_source('run-tests.cc') +bench_object = build.Ns3Module('bench-object', 'utils') +ns3.add(bench_object) +bench_object.set_executable() +bench_object.add_deps(['core']) +bench_object.add_source('bench-object.cc') + bench_packets = build.Ns3Module('bench-packets', 'utils') #ns3.add(bench_packets) bench_packets.set_executable() diff -r 956a76f5fd56 -r d845cfea2a16 utils/bench-object.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils/bench-object.cc Thu May 17 16:45:03 2007 +0200 @@ -0,0 +1,43 @@ +#include +#include +#include "ns3/interface-object.h" + +using namespace ns3; + +class BaseA : public ns3::InterfaceObject +{ +public: + static const ns3::MyInterfaceId iid; + BaseA () + { + SetInterfaceId (BaseA::iid); + } + virtual void Dispose (void) {} +}; + +const ns3::MyInterfaceId BaseA::iid = +ns3::MakeInterfaceId ("BaseABench", InterfaceObject::iid); + + + +int main (int argc, char *argv[]) +{ + int nobjects = atoi (argv[1]); + int nswaps = atoi (argv[2]); + + std::vector< Ptr > objlist; + + for (int i = 0; i < nobjects; ++i) + objlist.push_back (MakeNewObject ()); + + for (int swapCounter = nswaps; swapCounter; --swapCounter) + { + int x1 = swapCounter % nobjects; + int x2 = (swapCounter+1) % nobjects; + Ptr obj1 = objlist[x1]; + Ptr obj2 = objlist[x2]; + objlist[x2] = obj1; + objlist[x1] = obj2; + } +} +