コード例 #1
0
        /**
         * Run the actual benchmark.
         */
        public void RunPerformanceTest(int minPrefixLen, int maxPrefixLen,
                                       int num, bool onlyMorePopular)
        {
            Console.WriteLine(string.Format(CultureInfo.InvariantCulture,
                                            "-- prefixes: {0}-{1}, num: {2}, onlyMorePopular: {3}",
                                            //"-- prefixes: %d-%d, num: %d, onlyMorePopular: %s",
                                            minPrefixLen, maxPrefixLen, num, onlyMorePopular));

            foreach (Type cls in benchmarkClasses)
            {
                Lookup lookup = BuildLookup(cls, dictionaryInput);

                IList <string> input = new JCG.List <string>(benchmarkInput.size());
                foreach (Input tf in benchmarkInput)
                {
                    string s   = tf.term.Utf8ToString();
                    string sub = s.Substring(0, Math.Min(s.Length,
                                                         minPrefixLen + random.nextInt(maxPrefixLen - minPrefixLen + 1)));
                    input.Add(sub);
                }

                BenchmarkResult result = Measure(new PerformanceTestCallableIntHelper(this, input, lookup).Call);

                Console.WriteLine(
                    string.Format(CultureInfo.InvariantCulture, "{0,15}s queries: {1}, time[ms]: {2}, ~kQPS: {3:#.0}" /*"%-15s queries: %d, time[ms]: %s, ~kQPS: %.0f"*/,
                                  lookup.GetType().Name,
                                  input.size(),
                                  result.average.toString(),
                                  input.size() / result.average.avg));
            }
        }
コード例 #2
0
 public void TestStorageNeeds()
 {
     Console.WriteLine("-- RAM consumption");
     foreach (Type cls in benchmarkClasses)
     {
         Lookup lookup      = BuildLookup(cls, dictionaryInput);
         long   sizeInBytes = lookup.GetSizeInBytes();
         Console.WriteLine(
             string.Format(CultureInfo.InvariantCulture, "{0,15}s size[B]:{1:#,##0}" /*"%-15s size[B]:%,13d"*/,
                           lookup.GetType().Name,
                           sizeInBytes));
     }
 }