static void Main(string[] args) { if (args.Length != 3) { Console.WriteLine("Please specify: num_iterations num_objs dict|list"); return; } int num_iterations = Convert.ToInt32(args[0]); int num_objects = Convert.ToInt32(args[1]); if (args[2] == "dict") { DeepDictionaryList d_dict; for (int i = 0; i < num_iterations; i++) { d_dict = new DeepDictionaryList(num_objects); } } else if (args[2] == "list") { DeepListList d_list; for (int i = 0; i < num_iterations; i++) { d_list = new DeepListList(num_objects); } } else { Console.WriteLine("Unexpected class type"); } }
static void allocate(int num_iterations, int num_objects, string classType) { if (classType == "dict") { Int64 start = RegionAllocator.NativeGetPerformanceCounter(); DeepDictionaryList d_dict; for (int i = 0; i < num_iterations; i++) { d_dict = new DeepDictionaryList(num_objects); } Int64 end = RegionAllocator.NativeGetPerformanceCounter(); Print(end - start); } else if (classType == "list") { Int64 start = RegionAllocator.NativeGetPerformanceCounter(); DeepListList d_list; for (int i = 0; i < num_iterations; i++) { d_list = new DeepListList(num_objects); } Int64 end = RegionAllocator.NativeGetPerformanceCounter(); Print(end - start); } else { Console.WriteLine("Unexpected class type"); } }
static void allocateInRegion(int num_iterations, int num_objects, string classType) { if (classType == "dict") { Console.WriteLine("Can not allocate dict in region."); return; } else if (classType == "list") { Int64 start = RegionAllocator.NativeGetPerformanceCounter(); Region region = RegionAllocator.AllocateRegion(10000000); DeepListList d_list; for (int i = 0; i < num_iterations; i++) { d_list = new DeepListList(region, num_objects); } Int64 end = RegionAllocator.NativeGetPerformanceCounter(); Print(end - start); } else { Console.WriteLine("Unexpected class type"); } }
static void allocateInRegionContext(int num_iterations, int num_objects, string classType) { Region region = RegionAllocator.AllocateRegion(10000000); if (classType == "dict") { Int64 start = RegionAllocator.NativeGetPerformanceCounter(); using (RegionContext regContext = RegionContext.Create(region)) { DeepDictionaryList d_dict; for (int i = 0; i < num_iterations; i++) { d_dict = new DeepDictionaryList(num_objects); } } Int64 end = RegionAllocator.NativeGetPerformanceCounter(); Print(end - start); } else if (classType == "list") { Int64 start = RegionAllocator.NativeGetPerformanceCounter(); using (RegionContext regContext = RegionContext.Create(region)) { DeepListList d_list; for (int i = 0; i < num_iterations; i++) { d_list = new DeepListList(num_objects); } } Int64 end = RegionAllocator.NativeGetPerformanceCounter(); Print(end - start); } else { Console.WriteLine("Unexpected class type"); } }