/* * static void AddReference(ObjectWrapper parent, ObjectWrapper child) * { * //find an empty position to add a reference in the parent * //else use a random position * int position = GetRandomNumber(maxRef); * for (int i = 0; i < maxRef; i++) * { * if (parent.objRef[i] == null) * { * position = i; * break; * } * } * * parent.objRef[position] = child; * * } * */ public static int Main(string[] args) { // if (Environment.Is64BitProcess) pointerSize = 8; stopWatch.Start(); for (int i = 0; i < 3; i++) { currentCollections[i] = 0; } if (!ParseArgs(args)) { return(101); } dummyObject = new ObjectWrapper(0, 0, true, 0); objectCollection = new ObjArray(); objectCollection.Init(objCount); //One thread is in charge of updating the object age Thread thrd = new Thread(UpdateObjectAge); thrd.Start(); //another thread is removing expired objects Thread thrd2 = new Thread(RemoveExpiredObjects); thrd2.Start(); //another thread is removing weak references to dead objects Thread thrd3 = new Thread(RemoveWeakReferences); thrd3.Start(); // Run the test. for (int i = 0; i < numThreads; ++i) { Thread thread = new Thread(RunTest); threadList.Add(thread); thread.Start(i); } foreach (Thread t in threadList) { t.Join(); } testDone = true; return(100); }
/* static void AddReference(ObjectWrapper parent, ObjectWrapper child) { //find an empty position to add a reference in the parent //else use a random position int position = GetRandomNumber(maxRef); for (int i = 0; i < maxRef; i++) { if (parent.objRef[i] == null) { position = i; break; } } parent.objRef[position] = child; } * */ public static int Main(string[] args) { // if (Environment.Is64BitProcess) pointerSize = 8; stopWatch.Start(); for (int i = 0; i < 3; i++) { currentCollections[i] = 0; } if (!ParseArgs(args)) return 101; dummyObject = new ObjectWrapper(0, 0, true, 0); objectCollection = new ObjArray(); objectCollection.Init(objCount); //One thread is in charge of updating the object age Thread thrd = new Thread(UpdateObjectAge); thrd.Start(); //another thread is removing expired objects Thread thrd2 = new Thread(RemoveExpiredObjects); thrd2.Start(); //another thread is removing weak references to dead objects Thread thrd3 = new Thread(RemoveWeakReferences); thrd3.Start(); // Run the test. for (int i = 0; i < numThreads; ++i) { Thread thread = new Thread(RunTest); threadList.Add(thread); thread.Start(i); } foreach (Thread t in threadList) { t.Join(); } testDone = true; return 100; }