This page was last modified 08:05, 1 February 2008.
KIJ000806 - Using InputStream.skip() in S60 devices slows down MIDlet execution
From Forum Nokia Wiki
| ID | KIJ000806 | Creation date | January 31, 2008 |
| Platform | S60 2nd Edition, S60 3rd Edition, and S60 3rd Edition, FP1 | Devices | All S60 2nd Edition, S60 3rd Edition, and S60 3rd Edition, FP1 devices |
| Category | Java ME | Subcategory | MIDP 2.0 |
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");
}
Solution
The performance of skip() is improved in S60 3rd Edition, Feature Pack 2 resulting from the improved buffering when reading data from InputStreams.
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Questionnaire about RDA devices / firmware versions | bloodredsky | News, Announcements and Job Listings | 114 | 2008-07-16 15:45 |
| Concurrent midlet support in NOKIA Series 40 | nk_user | Mobile Java General | 1 | 2007-10-18 07:32 |
| Access to file with emulator | zidia | Mobile Java Media (Graphics & Sounds) | 5 | 2007-04-03 06:06 |
| 3650 Midi Stop Crash | Ncik | Mobile Java Media (Graphics & Sounds) | 2 | 2003-10-15 05:11 |
| Added command button automatically? | youngboyguy | General Symbian C++ | 0 | 2004-07-23 03:18 |

