Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Android / Standalone APK performance for files/String parsing/arrays ?

Author
Message
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 9th Feb 2013 02:27
I currently work for my Speed Racer Game which use files which populate arrays of 3000 elements.

When i use my game in broadcast mode (through the AppGameKit Player 108b8) (compiled by myself for android), populating arrays is very fast (1 second).

When i compile my game as a standalone APK (with the bytecode.byc) and run it, this is taking a lot of time ... (10 seconds !!!)

I simply loop over the lines in a file and i'm doing theses simple assignments :



I'm too lazy to test in depth lol but maybe someone already know this issue ? if not, i will investigate and determine if it's due to file reading, array populating, or GetStringToken command or valfloat ...

But it's very strange having this difference between the "broadcasted version" and the standalone version ... (based on the same player ... both versions compiled by myself !!)
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 9th Feb 2013 02:52
It seems to be a file reading problem ...

i will check the charset of the file maybe ...
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 9th Feb 2013 16:45 Edited at: 9th Feb 2013 17:25
hmmmf .. i can't explain this file's reading performance difference ....

considering myfile.txt containing 7000 lines of 64 chars long.

with a simple code like this :



in AppGameKit Player Android 108b8 on my device : less than 1 second.
in the compiled standalone app (based on same player) on the same device : 10 seconds ...

Tested on 5 android devices... same thing on each.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 25th Feb 2013 08:49
nobody knows ?
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 26th Feb 2013 12:27
My guess is that it takes longer to access the files within the apk. Try saving the data to a new file on your phone and then read from that.


Demo 3 is out now!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 26th Feb 2013 17:02
I think Digital Awakening has the right idea.

The first time you read the file, it is in the apk itself and needs to be extracted. If you do an initial read and then store it back to the same path, it will be put in the app sandbox area and probably read much faster after that.

Since this would be a one time process, check for a small file of any name that doesn't exist until the app is run. If the file does not exist, put up a message saying that a one time initialisation is being done. Then read the file and write it back and create the small file (only needs to be a single value) and it will be found the next time the app is run.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 26th Feb 2013 18:36 Edited at: 26th Feb 2013 18:38
ok .. i just understand ...

But it's still strange that 64 OBJ files (50KB each .. so 3MB at total) is read and rewritten faster than reading one file of 500KB (i'm doing some vertices transformations in theses OBJ files). Except if slowness only affects large files (could be possible...)

i'll keep you informed after my tests

Thanks for your help
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 26th Feb 2013 19:52
Sounds weird that multiple small files are read faster than a large file. If they are structured the same then having to access multiple files should take longer. Even when the total size is the same, multiple files should take longer. Is that the same for both the APK and the player?


Demo 3 is out now!
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 27th Feb 2013 00:39 Edited at: 27th Feb 2013 00:46
Bingo ! Works well if i copy my 500KB file in the app sandbox. it loads immediately. Thanks ! On this base ... why AppGameKit doesn't copy all the media directory content into the sandbox automagically at the first start ? :p (with a real copy and not reading the file content to rewrite it)

And yes... reading OBJ Files from APK or Player is about the same speed (files < 50KB). It could be possible that the allocated memory buffer to extract (decompress) APK files has a "max" size and after this size (imagine ... 128KB ?) it must allocate a file buffer instead of RAM etc etc ... but it's just an assumption which would explain that small files are extracted and opened a lot faster than "large" ones which could require more I/O from the filesystem itself.

maybe Paul could enlighten us on this strange thing ...

Login to post a reply

Server time is: 2024-11-23 12:30:33
Your offset time is: 2024-11-23 12:30:33