Codename One and Phonegap, a Performance Comparison
Total Page:16
File Type:pdf, Size:1020Kb
Codename One and PhoneGap, a performance comparison Andreas Arnesson Faculty of Computing Blekinge Institute of Technology SE-371 79 Karlskrona Sweden 1 Contact Information: Author: Andreas Arnesson [email protected] University advisor: Nina Dzamashvili Fogelström Department of Software Engineering Faculty of Computing Internet : www.bth.se Blekinge Institute of Technology Phone : +46 455 38 50 00 SE-371 79 Karlskrona Sweden Fax : +46 455 38 50 57 2 ABSTRACT Creating smartphone applications for more than one operating system requires knowledge of several code languages, more code maintenance, higher development costs and longer development time. To make this easier cross-platform tools (CPTs) exist. But using a CPT can decrease performance of the application. Applications with low performance are more likely to get uninstalled and this makes developers lose income. There are four main CPT approaches hybrid, interpreter, web and cross-compiler. Each has different disadvantages .and advantages. This study will examine the performance difference between two CPTs, Codename One and PhoneGap. The performance measurements, CPU load, memory usage, energy consumption, time execution and application size will be made to compare the CPTs. If cross-compilers have better performance than other CPT approaches will also be investigated. An experiment where three applications are created with native Android, Codename One and PhoneGap will be made and performance measurements will be made. A literature study with research from IEEE and Engineering village will be conducted on different CPT approaches. PhoneGap performed best with shortest execution time, least energy consumption and least CPU usage while Codename One had smallest application size and least memory usage. The research available on performance for CPTs is short and not well done. The difference between PhoneGap and Codename One is not big except for writing to SQLite. No basis was found for the statement that cross-compilers have better performance than other CPT approaches. Keywords: cross-platform tools, approach, performance, android 3 Table of Contents Abstract ................................................................................................................................................... 3 1 Introduction .......................................................................................................................................... 6 2 Background and Related work ............................................................................................................. 8 2.1 Background .................................................................................................................................... 8 2.1.1 Performance priority .............................................................................................................. 8 2.1.2 How my code affects performance ........................................................................................ 8 2.1.3 Different CPT approaches ..................................................................................................... 10 2.1.4 Why I chose these CPTs ........................................................................................................ 11 2.1.5 Android ................................................................................................................................. 11 2.2 Related work ............................................................................................................................... 13 3 Research design .................................................................................................................................. 16 3.1 Literature design ......................................................................................................................... 16 3.2 Experiment design ....................................................................................................................... 16 3.2.1 How to test my applications: ................................................................................................ 17 3.2.2 Validity threats ..................................................................................................................... 19 3.2.3 Performance tips from research .......................................................................................... 19 3.2.4 Measuring tools .................................................................................................................... 20 4 Results ................................................................................................................................................ 21 4.1 Literature review ......................................................................................................................... 21 4.1.1 Answer to literature question .............................................................................................. 23 4.2 Experiment .................................................................................................................................. 25 4.2.1 Result from Sony V ............................................................................................................... 25 4.2.2 Samsung Galaxy Trend plus .................................................................................................. 28 4.2.3 Application size ..................................................................................................................... 32 5 Analysis ............................................................................................................................................... 33 5.1 Memory usage ............................................................................................................................. 33 5.2 CPU load ...................................................................................................................................... 34 5.3 Execution time ............................................................................................................................. 34 5.4 Energy consumption .................................................................................................................... 35 5.5 Application size ............................................................................................................................ 35 5.6 Validity threats ............................................................................................................................ 36 4 5.7 Summary...................................................................................................................................... 36 6 Conclusion and future work ............................................................................................................... 38 6.1 Conclusion ................................................................................................................................... 38 6.2 Future work ................................................................................................................................. 38 References ............................................................................................................................................. 39 Appendix A – Bubble sort ...................................................................................................................... 42 5 1 Introduction By Q4, 2014 the smartphone market can be divided into five parts, Android, iOS, Windows phone, Blackberry and other OS’s [30]. Figure 1- Worldwide Smartphone OS Market Share. These four operating systems and others each use different languages to develop applications. For developers and companies who want to expand their market share beyond one OS, they need to maintain several projects instead of one. With this an increase of development time, development cost, maintenance and a bigger knowledge base is needed. Luckily there is hope for developers because nowadays tools are available for developing applications for multiple OS’s at once, so called cross-platform tools (CPTs). They have also been called Write once run everywhere. The pros of using CPTs are: [16] - Less skill required from developer. - Less coding needed. - Less development time and maintenance cost. - Less API knowledge. - Easier to develop one app instead of one for each OS. - More market share. Another problem with smartphones is their limited resources, CPU, memory, battery and data. The worst thing for a developer or company is for their application to get uninstalled from user’s smartphones. There are a number of reasons for this to happen, abusing privacy, unstable behavior, advertisement, no need for it anymore, high memory allocation, poor interface, high battery usage, low performance and sluggish behavior e.tc. Some of these reasons, high memory allocation, poor 6 interface, high battery usage, low performance and sluggish behavior, correlate to performance, CPU usage, memory usage, execution time and battery consumption. This means that if an application has low performance that application has a much higher risk of getting uninstalled and then developers and companies loses income. This is why it’s important for developers to always have in mind the resource use of their applications [31]. Using CPTs can come at a cost of resources. Using CPTs can decrease performance of application compared to native applications [21, 22]. That’s why it