static void Main(string[] args) { int threads = 0; DbManagerConfig config = new DbManagerConfig(); config.Type = "CacheDB.Net.implement.LevelDBManager,CacheDB.Net"; // config.Formater = "CacheDB.Net.implement.JsnoFormater, CacheDB.Net"; //config.Formater = "CacheDB.Net.implement.ProtobufFormater, CacheDB.Net"; //config.Formater = "CacheDB.Net.MsgpacketFormater.Formater,CacheDB.Net.MsgpacketFormater"; config.Formater = "CacheDB.Net.BinaryFormater.Formater,CacheDB.Net.BinaryFormater"; config.Properties.Add(new PropertyConfig { Name = "Path", Value = "test" }); db = Factory.CreateDBManager(config); db.Open(); START: Console.Clear(); Console.WriteLine("1.set test"); Console.WriteLine("2.get test"); string value = Console.ReadLine(); int menuid; int.TryParse(value, out menuid); if (menuid != 1 && menuid != 2) { goto START; } INPUT_THREADS: Console.Write("test thread(1-50):"); value = Console.ReadLine(); int.TryParse(value, out threads); if (threads < 1 || threads > 50) goto INPUT_THREADS; if (menuid == 1) { for (int i = 0; i < threads; i++) { System.Threading.ThreadPool.QueueUserWorkItem(WriteTest); } } else { Console.WriteLine("get key loading ..."); IEnumerator<KeyValuePair<byte[], byte[]>> items = db.DataBase.GetEnumerator(); while (items.MoveNext()) { keys.Add(Encoding.UTF8.GetString(items.Current.Key)); } Console.WriteLine("get testing ..."); for (int i = 0; i < threads; i++) { System.Threading.ThreadPool.QueueUserWorkItem(ReadTest); } } while (true) { Console.ForegroundColor = ConsoleColor.Green; if (menuid == 1) { Console.Write("set testing ..."); } else { Console.Write("get testing ..."); } System.Threading.Thread.Sleep(1000); Console.WriteLine(" [{0}/{1}]", mCount - mLastCount, mCount); mLastCount = mCount; } }
static void Main(string[] args) { int threads = 0; DbManagerConfig config = new DbManagerConfig(); config.Type = "CacheDB.Net.implement.LevelDBManager,CacheDB.Net"; // config.Formater = "CacheDB.Net.implement.JsnoFormater, CacheDB.Net"; //config.Formater = "CacheDB.Net.implement.ProtobufFormater, CacheDB.Net"; //config.Formater = "CacheDB.Net.MsgpacketFormater.Formater,CacheDB.Net.MsgpacketFormater"; config.Formater = "CacheDB.Net.BinaryFormater.Formater,CacheDB.Net.BinaryFormater"; config.Properties.Add(new PropertyConfig { Name = "Path", Value = "test" }); db = Factory.CreateDBManager(config); db.Open(); START: Console.Clear(); Console.WriteLine("1.set test"); Console.WriteLine("2.get test"); string value = Console.ReadLine(); int menuid; int.TryParse(value, out menuid); if (menuid != 1 && menuid != 2) { goto START; } INPUT_THREADS: Console.Write("test thread(1-50):"); value = Console.ReadLine(); int.TryParse(value, out threads); if (threads < 1 || threads > 50) { goto INPUT_THREADS; } if (menuid == 1) { for (int i = 0; i < threads; i++) { System.Threading.ThreadPool.QueueUserWorkItem(WriteTest); } } else { Console.WriteLine("get key loading ..."); IEnumerator <KeyValuePair <byte[], byte[]> > items = db.DataBase.GetEnumerator(); while (items.MoveNext()) { keys.Add(Encoding.UTF8.GetString(items.Current.Key)); } Console.WriteLine("get testing ..."); for (int i = 0; i < threads; i++) { System.Threading.ThreadPool.QueueUserWorkItem(ReadTest); } } while (true) { Console.ForegroundColor = ConsoleColor.Green; if (menuid == 1) { Console.Write("set testing ..."); } else { Console.Write("get testing ..."); } System.Threading.Thread.Sleep(1000); Console.WriteLine(" [{0}/{1}]", mCount - mLastCount, mCount); mLastCount = mCount; } }