Suppose I am testing a Java server application. I know how much time it takes to finish the test. Now I’d like to know how much was spent on GC during that test. How can I do it? Answer The simplest way is to use the -Xloggc and -XX:-PrintGCTimeStamps options when starting up your JVM. I think it prints out
Tag: performance
for-loop very slow on Android device
I just ran into an issue while trying to write an bitmap-manipulating algo for an android device. I have a 1680×128 pixel Bitmap and need to apply a filter on it. But this very simple code-piece actually took almost 15-20 seconds to run on my Android device (xperia ray with a 1Ghz processor). So I tried to find the bottleneck
Heap allocation and suitable hardware
For a C# .net 3.5 application which unavoidably creates a lot of data on the heap, in terms of hardware what would I be looking for in terms of memory? Would it just be the largest socket bus width? Or the “bandwidth” of the memory sticks? Or the actual frequency they run at? We have concluded the bottleneck of our
Fastest way to iterate over all the chars in a String
In Java, what would the fastest way to iterate over all the chars in a String, this: Or this: EDIT : What I’d like to know is if the cost of repeatedly calling the charAt method during a long iteration ends up being either less than or greater than the cost of performing a single call to toCharArray at the
Java CharAt() and deleteCharAt() performance
I’ve been wondering about the implementation of charAt function for String/StringBuilder/StringBuffer in java what is the complexity of that ? also what about the deleteCharAt() in StringBuffer/StringBuilder ? Answer For String, StringBuffer, and StringBuilder, charAt() is a constant-time operation. For StringBuffer and StringBuilder, deleteCharAt() is a linear-time operation. StringBuffer and StringBuilder have very similar performance characteristics. The primary difference is
What is the most efficient way to access particular elements in a SortedSet?
I want to use a collection that is sorted, but one in which I can access elements by index, i.e. I want something that has characteristics of both a Set and a List. Java.util.TreeSet comes real close to what I need, but doesn’t permit access via an index. I can think of several options: I could iterate through a TreeSet
Hibernate : dynamic-update dynamic-insert – Performance Effects
Using dynamic-update or dynamic-insert has positive, though generally slight only on performance, as also mentioned by http://www.mkyong.com/hibernate/hibernate-dynamic-update-attribute-example/ But the reference documentation mentions that this could have negative performance effects also as mentioned below in http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html#mapping-declaration-class : Although these settings can increase performance in some cases, they can actually decrease performance in others. Can anybody please suggest some example/scenario mentioning negative
How to monitor slow SQL queries executed by JPA and Hibernate
Is there any Hibernate property I could set to see all the slow queries? I’, interested in queries that take too much time to return the result set. I’m using Spring with Hibernate, configured via an applicationContext.xml Spring configuration file. Answer I have 2 suggestions: you could use Oracle’s Statspack. you could use some kind of JDBC proxy driver logging
Performance in Java through code? [closed]
First of all I should mention that I’m aware of the fact that performance optimizations can be very project specific. I’m mostly not facing these special issues right now. I’m facing a bunch of …
What is more efficient: System.arraycopy or Arrays.copyOf?
The toArray method in ArrayList, Bloch uses both System.arraycopy and Arrays.copyOf to copy an array. How can I compare these two copy methods and when should I use which? Answer The difference is that Arrays.copyOf does not only copy elements, it also creates a new array. System.arraycopy copies into an existing array. Here is the source for Arrays.copyOf, as you