private void LongRunTest() { Console.Clear(); Console.WriteLine(@"Consider this test takes several minutes!!!!"); Console.WriteLine(); Console.WriteLine(@"Clear Cache"); Console.WriteLine(); Common.Util.CacheClear(); Console.WriteLine("Fill Cache with some information"); Console.WriteLine(@"Adding 1000 Objects - inclusive allocation"); for (int i = 0; i < 1000; ++i) { Console.Write(". "); int r = new Random().Next(1,4); Thread.Sleep(r * 10); switch (r) { case 1: Common.Util.CacheAdd(@"1_A" + "_" + System.Diagnostics.Process.GetCurrentProcess().Id + i.ToString(), new TestSizeObject(ObjectSize.One)); break; case 2: Common.Util.CacheAdd(@"100_A" + "_" + System.Diagnostics.Process.GetCurrentProcess().Id + i.ToString(), new TestSizeObject(ObjectSize.Hundert)); break; case 3: Common.Util.CacheAdd(@"1000_A" + "_" + System.Diagnostics.Process.GetCurrentProcess().Id + i.ToString(), new TestSizeObject(ObjectSize.Thousend)); break; default: break; } } Console.WriteLine(@"Simulate single user with wait perioud of 0.5 - 1 sec."); List<string> keys = Common.Util.CacheGetAllKeys(); foreach (string key in keys) { Console.Write(". "); int r = new Random().Next(500, 1000); Thread.Sleep(r); TestSizeObject t = Common.Util.CacheGet<TestSizeObject>(key); if (t == null) { throw new Exception("Object was not available in cache therefore test aborted!!"); } } Console.WriteLine("Delete some keys from the cache also with sleep times between 0.5 - 0.8 sec."); for (int i = 0; i < keys.Count; i++) { Console.Write(". "); int d = new Random().Next(4, 8); if (i % d == 0) { Common.Util.CacheRemove(keys[i]); } int r = new Random().Next(500, 800); Thread.Sleep(r); } Console.WriteLine("Simulate several clients"); ConCurrentClient client = new ConCurrentClient(); Thread thread = new Thread(client.DoIt); thread.Start(); Common.Util.CacheClear(); }
/// <summary> /// Starts the test applicaiton /// </summary> public void Start() { Console.WriteLine(@"Welcome - This is Shared Cache test application."); bool doBreak = true; do { Menu.PrintMenu(); Console.WriteLine(); Console.Write("Enter your choice and press enter: "); try { #region switch switch (Console.ReadLine()) { case "": { Console.Clear(); break; } case "0": { lastSelectMenuOption = "0"; Console.Clear(); break; } case "1": { lastSelectMenuOption = "1"; UserData(); break; } case "5": { lastSelectMenuOption = "5"; PrintSettings(); break; } case "9": { lastSelectMenuOption = "9"; doBreak = false; break; } case "100": { lastSelectMenuOption = "100"; this.TestCountryMethod(true, true); break; } case "110": { lastSelectMenuOption = "110"; this.TestCountryMethod(false, true); break; } case "120": { lastSelectMenuOption = "120"; this.TestCountryMethod(false, false); break; } case "130": { lastSelectMenuOption = "130"; this.TestCountryMethodRandomize(false); break; } case "200": { lastSelectMenuOption = "200"; UserData(); break; } case "300": { lastSelectMenuOption = "300"; MultiOperation(ObjectSize.Hundert, 100); break; } case "310": { lastSelectMenuOption = "310"; RegExTestCase(); break; } case "400": { lastSelectMenuOption = "400"; CompareComressionUsage(); break; } case "410": { ConCurrentClient client = new ConCurrentClient(); Thread thread = new Thread(client.DoIt); thread.Start(); break; } case "420": { CallDataWhichIsNotAvailable(); break; } case "500": { lastSelectMenuOption = "500"; Console.Clear(); Console.WriteLine(); Console.WriteLine(); // we provide her null while upon testing normally just one server is available // TODO: in future it will search within the provider for all servers and send the request over each defined server Console.WriteLine(Common.Util.CacheGetStats()); Console.WriteLine(); Console.WriteLine(@"Operation Done"); Console.WriteLine(@"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); Console.WriteLine(); Console.WriteLine(@"Press enter to go on."); Console.ReadLine(); Console.Clear(); break; } case "510": { lastSelectMenuOption = "510"; this.RetrieveRandomizeKey(100); break; } case "520": { lastSelectMenuOption = "520"; Console.Clear(); Console.WriteLine(@"A list with all available Key's"); Console.WriteLine(); // we provide her null while upon testing normally just one server is available // TODO: in future it will search within the provider for all servers and send the request over each defined server List<string> keys = Common.Util.CacheGetAllKeys(); keys.Sort(); foreach (string key in keys) { Console.WriteLine(@"Key: {0}", key.ToString()); } Console.WriteLine(@"Total amount of items in sharedcache: {0}", keys.Count.ToString()); Console.WriteLine(); Console.WriteLine(@"Operation Done"); Console.WriteLine(@"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); Console.WriteLine(); Console.WriteLine(@"Press enter to go on."); Console.ReadLine(); Console.Clear(); break; } case "530": { lastSelectMenuOption = "530"; Console.Clear(); Console.WriteLine(@"Clear Cache"); Console.WriteLine(); // clear cache Common.Util.CacheClear(); Console.WriteLine(); Console.WriteLine(@"Operation Done"); Console.WriteLine(@"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "); Console.WriteLine(); Console.WriteLine(@"Press enter to go on."); Console.ReadLine(); Console.Clear(); break; } case "540": { lastSelectMenuOption = "540"; CheckHitRatio(); break; } case "550": { lastSelectMenuOption = "550"; CheckKeyWithSpecialCharset(); break; } case "560": { lastSelectMenuOption = "560"; AddSimpleTypeToCache(); break; } case "570": { lastSelectMenuOption = "570"; TestStatsAndAllKeys(); break; } case "580": { lastSelectMenuOption = "580"; CheckAbsolutExpiraitonTime(); break; } case "600": { lastSelectMenuOption = "600"; CompareObjectWithAndWithoutList(ObjectSize.Hundert, 100); break; } case "610": { lastSelectMenuOption = "610"; CompareObjectWithAndWithoutList(ObjectSize.Hundert, 1000); break; } case "700": { lastSelectMenuOption = "700"; AddObjectsWithOffset(ObjectSize.Hundert, 1); break; } case "710": { lastSelectMenuOption = "710"; ExtendItemTtl(); break; } case "800": { lastSelectMenuOption = "800"; LongRunTest(); break; } case "900": { lastSelectMenuOption = "900"; PerformanceTestCompare(); break; } case "1000": { lastSelectMenuOption = "1000"; DataContractTester(); break; } } #endregion switch } catch (Exception ex) { Console.WriteLine(@"An exception appears [feel free to contact us at: [email protected]]" + Environment.NewLine + ex.Message); } } while (doBreak); }