Ejemplo n.º 1
0
        public void CheckAllPossibleFieldsFastSpeed()
        {
            Skip.If(!Config.ENABLE_PROFILING);
            LOG.Info("Create analyzer");
            Stopwatch         stopwatch = Stopwatch.StartNew();
            UserAgentAnalyzer uaa       = UserAgentAnalyzer
                                          .NewBuilder()
                                          .KeepTests()
                                          .DelayInitialization()
                                          .Build();

            stopwatch.Stop();
            long constructMsecs = stopwatch.ElapsedMilliseconds;;

            LOG.Info(string.Format("-- Construction time: {0}ms", constructMsecs));

            LOG.Info("List fieldnames");
            stopwatch.Restart();
            foreach (var n in uaa.GetAllPossibleFieldNamesSorted())
            {
                LOG.Info(n);
            }
            stopwatch.Stop();
            long listFieldNamesMsecs = stopwatch.ElapsedMilliseconds;

            LOG.Info(string.Format("-- List fieldnames: {0}ms", listFieldNamesMsecs));
            listFieldNamesMsecs.Should().BeLessThan(500, "Just listing the field names should only take a few ms");

            LOG.Info("Initializing the datastructures");
            stopwatch.Restart();
            uaa.InitializeMatchers();
            stopwatch.Stop();
            long initializeMsecs = stopwatch.ElapsedMilliseconds;

            LOG.Info(string.Format("-- Initialization: {0}ms", initializeMsecs));
            initializeMsecs.Should().BeGreaterThan(300, "The initialization should take several seconds");

            LOG.Info("Preheat");
            stopwatch.Restart();
            uaa.PreHeat();
            stopwatch.Stop();
            long preheatMsecs = stopwatch.ElapsedMilliseconds;

            LOG.Info(string.Format("-- Preheat : {0}ms", preheatMsecs));
        }