Skip to main content

Posts

Showing posts with the label performance

Is Hibernate an overkill for an Android application?

I'm looking for a good ORM for my android application and at first glance it seems like for a mobile device I would prefer to use something simpler maybe. The thing is I'm just assuming here with no real evidence, so I thought I would ask the community's opinion (maybe there's is someone that has been through the experience). It is a fairly large(for mobile) application and will be run on a dedicated tablet. What does everyone else think ? Is Hibernate too much for an android application ? Will there be performance problems ? What would you use instead if you think it is too much ? I am aware there are other questions asking for alternatives, but I decided to ask since most of those questions simply assumed it was an overkill and asked for other options and I started wondering "Is it really and overkill ? Why ?" Due to my lack of experience I simply think it it, but can't really provide an answer if I'm asked to explain why. Is it performance ?

Android ContentProvider Performance

I'm curious if anyone has done any performance testing on querying a ContentProvider via ContentResolver vs querying a SQLiteDatabase object in the same process. I'm guessing that a ContentResolver query passes back a Cursor that communicates with the database through a Binder (Android IPC). This means that if I read the contents of 100 records through the Cursor that would result 100 Binder method calls. Are my guesses correct and if so would that be significantly slower than accessing the database in the same process? Source: Tips4all

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()

Why are annotations under Android such a performance issue (slow)?

I'm the lead author of ORMLite which uses Java annotations on classes to build database schemas. A big startup performance problem for our package turns out to be the calling of annotation methods under Android 1.6. I see the same behavior up through 3.0. We are seeing that the following simple annotation code is incredibly GC intensive and a real performance problem. 1000 calls to an annotation method takes almost a second on a fast box. The same code under Java can do 28 million (sic) calls in the same time. We have an annotation that has 25 methods in it and we'd like to do more than 50 of these a second. Does anyone know why this is happening and if there is any work around? There are certainly things that ORMLite can do in terms of caching this information but is there anything that we can do to "fix" annotations under Android? Thanks. public void testAndroidAnnotations() throws Exception { Field field = Foo.class.getDeclaredField("field");

Why do people use jQuery for basic operations?

I am a JS programmer and I have been experimenting with jQuery a lot but have run into a couple puzzling aspects. I feel like people use jQuery for much more than necessary. I really just want to know why picking jQuery may be better than using just pure JS. I know it makes sense for webfx like the animate and fades but for things like adding event listeners it seems just as easy to use obj = document.getElementByID(_ID_); obj.addEventListener("mousedown"...); An example of this is the answer I found on StackOverflow earlier today about performing an action for highlighted text. jQuery: get the highlighted text In the example linked in the answer at http://mark.koli.ch/2009/09/use-javascript-and-jquery-to-get-user-selected-text.html The guy uses the bind function to the document. Why use bind rather than addEventListener. Also with jQuery everything needs to be included in the .ready() method how is this better than (or why choose it over) document.addEventListene

Obsolete Java Optimization Tips

There are number of performance tips made obsolete by Java compiler and especially Profile-guided optimization . For example, these platform-provided optimizations can drastically (according to sources) reduces the cost of virtual function calls. VM is also capable of method inlining, loop unrolling etc. What are other performance optimization techniques you came around still being applied but are actually made obsolete by optimization mechanisms found in more modern JVMs?

Size of a byte in memory - Java

I have heard mixed opinions over the amount of memory that a byte takes up in a java program. I am aware you can store no more than +127 in a java byte, and the documentation says that a byte is only 8 bits but here I am told that it actually takes up the same amount of memory as an int, and therefore is just a Type that helps in code comprehension and not efficiency. Can anyone clear this up, and would this be an implementation specific issue?

Ways to improve performance consistency

In the following example, one thread is sending "messages" via a ByteBuffer which is the consumer is taking. The best performance is very good but its not consistent. public class Main { public static void main(String... args) throws IOException { for (int i = 0; i < 10; i++) doTest(); } public static void doTest() { final ByteBuffer writeBuffer = ByteBuffer.allocateDirect(64 * 1024); final ByteBuffer readBuffer = writeBuffer.slice(); final AtomicInteger readCount = new PaddedAtomicInteger(); final AtomicInteger writeCount = new PaddedAtomicInteger(); for(int i=0;i<3;i++) performTiming(writeBuffer, readBuffer, readCount, writeCount); System.out.println(); } private static void performTiming(ByteBuffer writeBuffer, final ByteBuffer readBuffer, final AtomicInteger readCount, final AtomicInteger writeCount) { writeBuffer.clear(); readBuffer.clear();

Very slow query where table have many records

I' m using sqlite on iphone. I have table with 200 000 records. It' s size is small, only 2 MB. I' m doing standard select(3 collumns) with two simple condtions. I' m operating only on integer values( in return and condtion). All data are unique. I'm get usually only 10-50 records from database. In spite of that my query take 3 sec. It' s a lot of time. How i can improve this ? Edit: I can't load my table with other thread. NSString * query = [ NSString stringWithFormat:@"SELECT rRozklad.hour, rRozklad.minute, rRozklad.marks FROM rRozklad.idOkres=%i AND rRozklad.idPolaczeniaLinie=2 ORDER by rRozklad.hour, rRozklad.minute", okres]; NSLog(@"%@", query); const char * querystring = [ query UTF8String ]; sqlite3_stmt * statment; if(sqlite3_prepare_v2(database, querystring, -1, &statment, nil) == SQLITE_OK){ while(sqlite3_step(statment) == SQLITE_ROW){ NSMutableArray * temp = [[NSMutableArray alloc] initWithCapacity:2];

Swing high-performance charting library

I'm currently looking for a Swing component that will allow me to draw about 5000 points per sequence for at least 3 sequences with an update frequency greater or equal to 100 Hz (and preferably pretty looks). A clean API is definitely a plus and another plus is the possibility of having two (or more) vertical axes. The targets are java 6 and 7. Solutions which are not 100% java should support at least Windows 7 and Mac OS X Lion. Commercial and F/OSS solutions equally welcome. Thanks in advance

How can I import java.awt.BufferedImage in an Android project?

I see answers to questions suggesting the use of BufferedImages for performing increases that I am very interested in. How can I avoid garbage collection delays in Java games? (Best Practices) But I cannot find out a way to import it because it is not part of the SDK of course. How has everyone else who have used it achieved this? I am basically looking for a way to store graphics I am writing on canvas without having to build them totally from stratch each time. For example storing a drawText() as a BufferedImage and drawing that each frame.