Esempio n. 1
0
        public void GetByIndex()
        {
            var source = new AddressParser(Log, FolderWithLucene);

            var list = new string[]
            {
                "658390",
                "659063",
                "397670",
            };

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

                    var b = DateTime.UtcNow.Ticks;
                    var collection = source.GetByIndex(index);

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

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