Improving performance of WURFL code

249 views Asked by At

I tested the following code which prints the properties of the UserAgent. However I notice that it takes noticeable time to execute the code.

// Initialize the WURFL library. 
String projRoot = System.getProperty("user.dir");
wurflFile = projRoot + File.separator + "wurfl-2.3.3" + File.separator + "wurfl.xml";

File dataFile = new File(wurflFile);
wurfl = new CustomWURFLHolder(dataFile);

String deviceUrl = "Apple-iPhone5C1";

WURFLManager manager = wurfl.getWURFLManager();
Device device = manager.getDeviceForRequest(deviceUrl);

System.out.println("Device: " + device.getId());
System.out.println("Capability: " + device.getCapability("preferred_markup"));
System.out.println("Device UA: " + device.getUserAgent());

Map capabilities = device.getCapabilities();
System.out.println("Size of the map: " + capabilities.keySet().size());
Iterator itr = capabilities.keySet().iterator();
while (itr.hasNext()) {
  String str = (String) itr.next();
    System.out.println(str);
}

One of the reason is that it takes time to load and parse the WURFL XML database file (which is about 20MB size).

I want to know if there is any different WURFL API, which will improve this performance? Eventually, I would be putting this code in a HTTP Proxy where I want to check the device profile parameter for adaptation of the content.

Thanks.

0

There are 0 answers