public void ProfileMemoryFootprint() { Skip.If(!Config.ENABLE_PROFILING); PrintCurrentMemoryProfile("Before "); UserAgentAnalyzer uaa = UserAgentAnalyzer .NewBuilder() .HideMatcherLoadStats() .WithoutCache() .KeepTests() .Build(); PrintCurrentMemoryProfile("Loaded "); uaa.InitializeMatchers(); PrintCurrentMemoryProfile("Init "); GC.Collect(); PrintCurrentMemoryProfile("Post GC"); uaa.SetCacheSize(1000); uaa.PreHeat(); GC.Collect(); PrintCurrentMemoryProfile("Cache 1K"); uaa.SetCacheSize(10000); uaa.PreHeat(); GC.Collect(); PrintCurrentMemoryProfile("Cache 10K"); uaa.DropTests(); GC.Collect(); PrintCurrentMemoryProfile("NoTest "); }
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)); }