Java Code Examples for nl.basjes.parse.useragent.UserAgentAnalyzer#preHeat()
The following examples show how to use
nl.basjes.parse.useragent.UserAgentAnalyzer#preHeat() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestMemoryFootprint.java From yauaa with Apache License 2.0 | 6 votes |
@Disabled @Test public void checkForMemoryLeaksDuringRuns() { //NOSONAR: Do not complain about ignored performance test UserAgentAnalyzer uaa = UserAgentAnalyzer .newBuilder() .withoutCache() // .withField("OperatingSystemName") // .withField("OperatingSystemVersion") // .withField("DeviceClass") .hideMatcherLoadStats() .keepTests() .build(); LOG.info("Init complete"); int iterationsDone = 0; final int iterationsPerLoop = 1000; for (int i = 0; i < 100; i++) { long start = System.nanoTime(); uaa.preHeat(iterationsPerLoop, false); long stop = System.nanoTime(); iterationsDone += iterationsPerLoop; long averageNanos = (stop - start) / iterationsPerLoop; printMemoryUsage(iterationsDone, averageNanos); } }
Example 2
Source File: TestPerformance.java From yauaa with Apache License 2.0 | 5 votes |
@Test public void checkAllPossibleFieldsFastSpeed() { LOG.info("Create analyzer"); long start = System.nanoTime(); UserAgentAnalyzer uaa = UserAgentAnalyzer .newBuilder() .keepTests() .delayInitialization() .build(); long stop = System.nanoTime(); long constructMsecs = (stop - start) / 1000000; LOG.info("-- Construction time: {}ms", constructMsecs); LOG.info("List fieldnames"); start = System.nanoTime(); uaa.getAllPossibleFieldNamesSorted() .forEach(LOG::info); stop = System.nanoTime(); long listFieldNamesMsecs = (stop - start) / 1000000; LOG.info("-- List fieldnames: {}ms", listFieldNamesMsecs); assertTrue(listFieldNamesMsecs < 500, "Just listing the field names should only take a few ms"); LOG.info("Initializing the datastructures"); start = System.nanoTime(); uaa.initializeMatchers(); stop = System.nanoTime(); long initializeMsecs = (stop - start) / 1000000; LOG.info("-- Initialization: {}ms", initializeMsecs); // assertTrue("The initialization went too fast, this should take several seconds", initializeMsecs > 100); LOG.info("Preheat"); start = System.nanoTime(); uaa.preHeat(); stop = System.nanoTime(); long preheatMsecs = (stop - start) / 1000000; LOG.info("-- Preheat : {}ms", preheatMsecs); }
Example 3
Source File: TestMemoryFootprint.java From yauaa with Apache License 2.0 | 5 votes |
@Disabled @Test public void profileMemoryFootprint() { //NOSONAR: Do not complain about ignored performance test printCurrentMemoryProfile("Before "); UserAgentAnalyzer uaa = UserAgentAnalyzer .newBuilder() .hideMatcherLoadStats() .withoutCache() .keepTests() .build(); printCurrentMemoryProfile("Loaded "); uaa.initializeMatchers(); printCurrentMemoryProfile("Init "); Runtime.getRuntime().gc(); printCurrentMemoryProfile("Post GC"); uaa.setCacheSize(1000); uaa.preHeat(); Runtime.getRuntime().gc(); printCurrentMemoryProfile("Cache 1K"); uaa.setCacheSize(10000); uaa.preHeat(); Runtime.getRuntime().gc(); printCurrentMemoryProfile("Cache 10K"); uaa.dropTests(); Runtime.getRuntime().gc(); printCurrentMemoryProfile("NoTest "); }
Example 4
Source File: TestMemoryFootprint.java From yauaa with Apache License 2.0 | 4 votes |
@Disabled @Test public void assesMemoryImpactPerFieldName() { //NOSONAR: Do not complain about ignored performance test // Get the Java runtime Runtime runtime = Runtime.getRuntime(); // Calculate the used memory long memory = runtime.totalMemory() - runtime.freeMemory(); LOG.error(String.format( "Without Yauaa present and GC --> Used memory is %10d bytes (%5d MiB)", memory, bytesToMegabytes(memory))); UserAgentAnalyzer uaa = UserAgentAnalyzer .newBuilder() .hideMatcherLoadStats() .withoutCache() .keepTests() .build(); uaa.preHeat(); runtime.gc(); uaa.preHeat(); runtime.gc(); // Calculate the used memory memory = runtime.totalMemory() - runtime.freeMemory(); LOG.error(String.format( "Querying for 'All fields' and GC --> Used memory is %10d bytes (%5d MiB)", memory, bytesToMegabytes(memory))); for (String fieldName : uaa.getAllPossibleFieldNamesSorted()) { uaa = UserAgentAnalyzer .newBuilder() .withoutCache() .withField(fieldName) .hideMatcherLoadStats() .keepTests() .build(); uaa.preHeat(); runtime.gc(); uaa.preHeat(); runtime.gc(); // Calculate the used memory memory = runtime.totalMemory() - runtime.freeMemory(); LOG.error(String.format( "Querying for %s and GC --> Used memory is %10d bytes (%5d MiB)", fieldName, memory, bytesToMegabytes(memory))); } }