Namespaces
Variants
Actions

Archived:Using InputStream.skip() slows down MIDlet execution in S60 2nd and 3rd Edition (Known Issue)

Jump to: navigation, search
Archived.png
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.


Article Metadata

Tested with
Devices(s): All S60 2nd Edition, S60 3rd Edition, and S60 3rd Edition FP1 devices

Compatibility
Platform(s): S60 2nd Edition, S60 3rd Edition, and S60 3rd Edition FP1

Article
Created: User:Technical writer 1 (31 Jan 2008)
Last edited: hamishwillee (28 Jun 2012)

Overview

Using the InputStream.skip() method in S60 devices causes significantly slow MIDlet execution.

Description

The InputStream.skip(long n) method skips and discards n bytes of data from the input stream.

When skipping a large amount of bytes (for example, 500000 bytes) several times with S60 devices, the method causes significantly slow MIDlet execution: with S60 3rd Edition and S60 3rd Edition, Feature Pack 1 phones this means between 5 to 10 seconds, whereas with S60 2nd Edition phones this can be even over 20 seconds. Comparison of S60 and Series 40 shows that using the skip() method with S60 devices is approximately 5 to 9 times (or even more) slower when skipping a large amount of bytes.

How to reproduce

S60 and Series 40 devices are required for comparison.

The following piece of code reads the contents of a text file into the InputStream object. All the read content will be sent to skip() by using the available() method, and the time which the operation of the skip() method takes is measured. With this example, the previous procedures will be repeated 20 times by using a for-loop to visualize the slow execution.

 InputStream instr;
long startTime = System.currentTimeMillis();
Form f;
...
for( num=0; num<20; num++){
 
instr=getClass().getResourceAsStream("textfile.txt");
instr.skip(instr.available());
long timePassed = System.currentTimeMillis() - startTime;
f.append("Round: "+(num+1)+", Time(ms): "+timePassed+"\n");
 
}
<code>
 
==Solution==
The performance of {{Icode|skip()}} is improved in S60 3rd Edition, Feature Pack 2 resulting from the improved buffering when reading data from InputStreams.
This page was last modified on 28 June 2012, at 08:54.
185 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved