/*
 * Yet Another UserAgent Analyzer
 * Copyright (C) 2013-2016 Niels Basjes
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

package nl.basjes.parse.useragent;

import nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TestPerformance {
    private static final Logger LOG = LoggerFactory.getLogger(TestPerformance.class);

    @Ignore
    @Test
    public void validateAllPredefinedBrowsersPerformance() {
        UserAgentAnalyzerTester uaa = new UserAgentAnalyzerTester();
        Assert.assertTrue(uaa.runTests(false, false, true));
    }

    @Ignore
    @Test
    public void performanceTestNoCache() {
        runPerformanceTest(false,   10000);
    }

    @Ignore
    @Test
    public void performanceTestCached() {
        runPerformanceTest(true, 1000000);
    }

    private void runPerformanceTest(boolean cached, long count) {
        UserAgentAnalyzer uaa = new UserAgentAnalyzer();
        if (!cached) {
            uaa.disableCaching();
        }

        UserAgent agent = new UserAgent("Mozilla/5.0 (Linux; Android 6.0; Nexus 6 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36");

        // Preheat the jit compiler.
        for (int i = 0; i < 500; i++) {
            agent.reset();
            uaa.parse(agent);
        }

        long start = System.nanoTime();
        LOG.info("Start @ {}", start);
        // Try to repeatedly parse a 'normal' agent without any caching.
        for (int i = 0; i < count; i++) {
            agent.reset();
            uaa.parse(agent);
        }
        long stop = System.nanoTime();
        LOG.info("Stop  @ {}", stop);
        LOG.info("Did {} in {} ns ({} sec)--> {}/sec", count, stop-start, (stop-start)/1000000000 , (1000000000*count)/(stop-start));
    }

}

@@ -1300,1231 +1300,6 @@
  %7D%0A%0A
-    @Ignore%0A    @Test%0A    public void performanceTestNoCache() %7B%0A        runPerformanceTest(false,   10000);%0A    %7D%0A%0A    @Ignore%0A    @Test%0A    public void performanceTestCached() %7B%0A        runPerformanceTest(true, 1000000);%0A    %7D%0A%0A    private void runPerformanceTest(boolean cached, long count) %7B%0A        UserAgentAnalyzer uaa = new UserAgentAnalyzer();%0A        if (!cached) %7B%0A            uaa.disableCaching();%0A        %7D%0A%0A        UserAgent agent = new UserAgent(%22Mozilla/5.0 (Linux; Android 6.0; Nexus 6 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36%22);%0A%0A        // Preheat the jit compiler.%0A        for (int i = 0; i %3C 500; i++) %7B%0A            agent.reset();%0A            uaa.parse(agent);%0A        %7D%0A%0A        long start = System.nanoTime();%0A        LOG.info(%22Start @ %7B%7D%22, start);%0A        // Try to repeatedly parse a 'normal' agent without any caching.%0A        for (int i = 0; i %3C count; i++) %7B%0A            agent.reset();%0A            uaa.parse(agent);%0A        %7D%0A        long stop = System.nanoTime();%0A        LOG.info(%22Stop  @ %7B%7D%22, stop);%0A        LOG.info(%22Did %7B%7D in %7B%7D ns (%7B%7D sec)--%3E %7B%7D/sec%22, count, stop-start, (stop-start)/1000000000 , (1000000000*count)/(stop-start));%0A    %7D%0A%0A
 %7D%0A

Remove obsolete performance tests