Beispiel #1
0
        private static void example_json_db()
        {
            INI_db db_tool = new INI_db();

            // Save DB
            System.Diagnostics.Stopwatch watch_save = new System.Diagnostics.Stopwatch();
            System.Diagnostics.Stopwatch watch_load = new System.Diagnostics.Stopwatch();
            Random rand = new Random();

            watch_save.Start();
            int k_group_num = 50; // 5x100
            int k_para_num  = 100;

            IniData db_mem = new IniData();

            for (int idx_group = 0; idx_group < k_group_num; idx_group++)
            {
                for (int idx_para = 0; idx_para < k_para_num; idx_para++)
                {
                    dynamic json_data = new JObject();
                    json_data.Integer = rand.Next();
                    json_data.Float   = rand.NextDouble();
                    db_tool.Insert(db_mem, $"Group_{idx_group}", $"Value_{idx_para}", json_data);
                }
            }
            db_tool.Save("json_db.ini", db_mem);
            watch_save.Stop();

            // Load DB
            watch_load.Start();
            db_mem = db_tool.Load("json_db.ini");
            for (int idx_group = 0; idx_group < k_group_num; idx_group++)
            {
                for (int idx_para = 0; idx_para < k_para_num; idx_para++)
                {
                    JObject j_default = new JObject();
                    JObject j         = db_tool.Load(db_mem, $"Group_{idx_group}", $"Value_{idx_para}", j_default);
                }
            }
            watch_load.Stop();

            System.Console.WriteLine($"json_db.ini save... {watch_save.ElapsedMilliseconds} ms");
            System.Console.WriteLine($"json_db.ini load... {watch_load.ElapsedMilliseconds} ms");
        }
Beispiel #2
0
        private static void example_db()
        {
            INI_db db_tool = new INI_db();

            // Save DB
            System.Diagnostics.Stopwatch watch_save = new System.Diagnostics.Stopwatch();
            Random rand = new Random();

            watch_save.Start();
            int     k_group_num = 50; // 5x100
            int     k_para_num  = 100;
            IniData db_mem      = new IniData();

            for (int idx_group = 0; idx_group < k_group_num; idx_group++)
            {
                for (int idx_para = 0; idx_para < k_para_num; idx_para++)
                {
                    //db.Save("data.ini", $"Group_{idx_group}", $"Value_{idx_para}", rand.NextDouble());
                    db_tool.Insert(db_mem, $"Group_{idx_group}", $"Value_{idx_para}", rand.NextDouble());
                    //System.Console.WriteLine("({0},{1})", idx_group, idx_para);
                }
            }
            db_tool.Save("data.ini", db_mem);
            watch_save.Stop();

            // Load DB
            System.Diagnostics.Stopwatch watch_load = new System.Diagnostics.Stopwatch();
            watch_load.Start();
            db_mem = db_tool.Load("data.ini");
            for (int idx_group = 0; idx_group < k_group_num; idx_group++)
            {
                for (int idx_para = 0; idx_para < k_para_num; idx_para++)
                {
                    //double f_value;
                    //db.TryLoad(db_mem, $"Group_{idx_group}", $"Value_{idx_para}", out f_value);
                    double f_value = db_tool.Load(db_mem, $"Group_{idx_group}", $"Value_{idx_para}", 0.0);
                    //System.Console.WriteLine("({0},{1}) = {2}", idx_group, idx_para, f_value);
                }
            }
            watch_load.Stop();
            System.Console.WriteLine($"data.ini save... {watch_save.ElapsedMilliseconds} ms");
            System.Console.WriteLine($"data.ini load... {watch_load.ElapsedMilliseconds} ms");
        }