Package org.apache.devicemap

Examples of org.apache.devicemap.DeviceMapClient


        if ("default".equals(loaderPath)) {
            loaderPath = null;
        }

        DeviceMapClient client = new DeviceMapClient();

        long start = System.currentTimeMillis();

        client.initDeviceData(option, loaderPath);

        long diff = System.currentTimeMillis() - start;

        System.out.println("Loaded " + client.getDeviceCount() + " devices with " + client.getPatternCount() +
                " patterns and " + client.getNodeCount() + " nodes in " + diff + "ms");

        String test = "Mozilla/5.0 (Linux; U; Android 2.2; en; HTC Aria A6380 Build/ERE27) AppleWebKit/540.13+ (KHTML, like Gecko) Version/3.1 Mobile Safari/524.15.0";

        long startn = System.nanoTime();

        Map<String, String> m = client.classify(test);

        long diffn = (System.nanoTime() - startn) / 1000;

        System.out.println("Test lookup: '" + m.get("id") + "' time: " + diffn + "usec");

        if (parameter == null) {
        } else if ((new File(parameter)).exists()) {
            System.out.println("Text file: " + parameter);

            int count = 0;
            int total = 0;

            BufferedReader in = new BufferedReader(new FileReader(parameter));
            String line;

            while ((line = in.readLine()) != null) {
                System.out.println("Text: '" + line + "'");

                startn = System.nanoTime();

                m = client.classify(line);

                diffn = System.nanoTime() - startn;

                total += diffn;
                count++;

                System.out.println("Text lookup " + count + ": '" + m.get("id") + "' time: " + (diffn / 1000) + "usec");
            }

            in.close();

            if (count == 0) {
                count = 1;
            }

            total /= count;

            System.out.println("TOTAL lookups: " + count + ", average time: " + (total / 1000) + "usec");
        } else {
            System.out.println("Text: '" + parameter + "'");

            startn = System.nanoTime();

            m = client.classify(parameter);

            diffn = System.nanoTime() - startn;

            System.out.println("Text lookup: '" + m.get("id") + "' time: " + (diffn / 1000) + "usec");
View Full Code Here

TOP

Related Classes of org.apache.devicemap.DeviceMapClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.