Пример #1
0
        public void Search()
        {
            var list = new string[]
            {
                "Адыгея, Майкоп, Краснодарская",
                "Воронежская, Петропавловский, Петропавловка, Садовая",
                "Московская, Балашиха, Русавкино-Романово, Энергетическая",
                "Балашиха Фадеева",
                "Фадеева Балашиха",
                "Респ Адыгея",
                "Адыгея"
            };

            var source = new AddressParser(Log, FolderWithLucene);

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

                    var b = DateTime.UtcNow.Ticks;
                    var collection = source.Search(filter);

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

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