示例#1
0
        public void GetChildren()
        {
            var source = new AddressParser(Log, FolderWithLucene);

            var list = new string[]
            {
                // 1
                "090000000000000",
                "890000000000000",

                // 2
                "110070000000000",
                "140280000000000",
                "660120000000000",

                // 3
                "020000030000000",
                "240020080000000",
                "540060040000000",

                // 4
                "500000360000000",
                "470130009190000",
                "010000010080000",
                "590190000480000",
                "710240002550000",
            };

            long total = 0;
            int count = 0;
            for (int i = 0; i < 10; i++)
            {
                foreach (var code in list)
                {
                    count++;

                    var b = DateTime.UtcNow.Ticks;

                    int level = source.GetLevel(code).Value + 1;
                    var collection = source.GetChildren(code);

                    System.Diagnostics.Trace.WriteLine(code + "...");
                    int? totalHits = null;
                    foreach (var d in collection)
                    {
                        if (!totalHits.HasValue)
                        {
                            totalHits = d.LastInfo.TotalHits;
                            System.Diagnostics.Trace.WriteLine("TotalHits: " + totalHits);
                        }

                        if (totalHits < 20) System.Diagnostics.Trace.WriteLine("    " + d.ToString());

                        try
                        {
                            Assert.That(d.Level, Is.GreaterThanOrEqualTo(level));
                        }
                        catch (Exception)
                        {
                            System.Diagnostics.Trace.WriteLine("warn:" + d.ToString());
                            throw;
                        }

                    }
                    total += (DateTime.UtcNow.Ticks - b);
                }
            }
            System.Diagnostics.Trace.WriteLine(string.Format("Total: {0} ms", 1.0 * total / (TimeSpan.TicksPerMillisecond * count)));
        }