Example #1
0
        public static void TestNameTable(INametable nt)
        {
            System.Diagnostics.Stopwatch T = new System.Diagnostics.Stopwatch();
            Random rnd    = new Random();
            string prefix = "PupkinQQUTEUJSHJDHJGFHSGDHWTYTHXCGHGCHSHSDYSTDSHSGHSG_";

            int max   = 1_000_000;
            int total = 7 * max;

            T.Restart();
            for (int i = 0; i < total; i++)
            {
                string scode = prefix + rnd.Next(max);
                var    code  = nt.GetSetCode(scode);
            }
            T.Stop();
            Console.WriteLine($" get set {total} codes for new strings time {T.ElapsedMilliseconds}. Nametable Count={nt.LongCount()}");


            int nprobes = 1_000_000;

            T.Restart();
            int unknown = 0;

            for (int j = 0; j < nprobes; j++)
            {
                string scode = prefix + rnd.Next(max);
                int    code  = nt.GetCode(scode);
                if (code == Int32.MinValue)
                {
                    unknown++;
                }
            }
            T.Stop();
            Console.WriteLine($" get {nprobes} codes. time {T.ElapsedMilliseconds}. {unknown} are unknown");

            T.Restart();
            unknown = 0;
            int maxcode = (int)nt.LongCount() * 11 / 10; // лишние для тестирования отсутствующих кодов

            for (int j = 0; j < nprobes; j++)
            {
                int    code  = rnd.Next(maxcode);
                string scode = nt.GetString(code);
                if (scode == null)
                {
                    unknown++;
                }
            }
            T.Stop();
            Console.WriteLine($" get {nprobes} string from codes. time {T.ElapsedMilliseconds}. {unknown} are unknown");
        }
Example #2
0
        public void TestNameTable()
        {
            Random        rnd    = new Random();
            string        prefix = "PupkinQQUTEUJSHJDHJGFHSGDHWTYTHXCGHGCHSHSDYSTDSHSGHSG_";
            int           max    = 1_000_000;
            int           total  = 7 * max;
            List <string> names  = Enumerable.Range(0, total).Select(i => prefix + rnd.Next(max)).ToList();
            List <int>    codes  = new List <int>();

            total++;
            names.Add(string.Empty);

            for (int i = 0; i < total; i++)
            {
                string scode = prefix + rnd.Next(max);
                var    code  = _magnt.GetSetCode(scode);
            }

            int nprobes = 1_000_000;

            int unknown = 0;

            for (int j = 0; j < nprobes; j++)
            {
                string scode = prefix + rnd.Next(max);
                int    code  = _magnt.GetCode(scode);
                if (code == Int32.MinValue)
                {
                    unknown++;
                }
            }
            unknown = 0;
            int maxcode = (int)_magnt.LongCount() * 11 / 10; // лишние для тестирования отсутствующих кодов

            for (int j = 0; j < nprobes; j++)
            {
                int    code  = rnd.Next(maxcode);
                string scode = _magnt.GetString(code);
                if (scode == null)
                {
                    unknown++;
                }
            }
        }