Per-unit-test profiling

Posted by Mike Haller on Monday, November 16. 2009 at 23:01 in Java
As a preparation for long-term performance measurements, (sometimes called Continuous Performance Management or CPM), I tried to automate the creation of JProfiler profiling snapshots and, along the way, came up with the following side product: Automated per-test method profiling.

Basically, the idea is to go from here:


to here




"What's so great about this?", you wonder?


Read the full article for fancy screenshots and code snippets.

(Btw, the test cases are due to this question. Usually, i don't do String performance tests ;-)

Top10 programming controversial

Posted by Mike Haller on Wednesday, November 4. 2009 at 11:02 in Java
There's a Stackoverflow question about controversial programming opinions:
The top ten as voted by the SO community:

1. The only "best practice" you should be using all the time is Use Your Brain
2. Most comments in code are in fact a pernicious form of code duplication
3. Programmers who don't code in their spare time for fun, will never become as good as those that do
4. Not all programmers are created equal
5. XML is highly overrated
6. "Googling it" is okay!
7. I fail to understand why people think that Java is absolutely the best "first" programming language to be taught in universities
8. If you only know *one language*, no matter how well you know it, you're not a great programmer
9. Performance does matter
10. The Business Apps farce (You have to read it to understand)


Where have all the threads gone?

Posted by Mike Haller on Monday, July 6. 2009 at 15:37 in Java
Recently, we got a nasty error in the log file:
java.lang.OutOfMemoryError: unable to create new native thread


Although we had specified -XX:HeapDumpOnOutOfMemoryError, this does not include dumping the heap to disk when the heap is not involved in an OutOfMemoryError. In this case, the JVM was unable to create new threads as the limit of threads was reached.

So, the question is: How many threads can be created?
The answer is, as usual: It depends!

My Own Twitter Client

Posted by Mike Haller on Sunday, May 17. 2009 at 22:01 in Java
Using twitter4j, it's pretty easy to hack together a new Twitter desktop client. What I wanted to do is to have search capabilities and have all the tweets in a local database, so I could have a look and work with the messages people write even when i'm offline (which never happens anyway, but just in case).

So, taking Eclipse RCP, munching it with twitter4j, adding a bit of Apache Derby and other stuff, I ended up with the following prototype in a couple of hours:



It has a virtual table, so it loads tweets on-demand from the local database when you scroll down. It only reloads the latest 20 tweets from Twitter.com in online mode. There is an offline-mode to decrease the amount of network bandwidth and service utilization. Twitter is already pretty slow. The client caches all the profile images for faster loading. It displays the time of the tweet and highlights URLs. I had a feature in it which resolves shortened URLs and displays the real ones on hover, but i disabled it as I've got problems displaying a nice hover. Hover's in Eclipse RCP/SWT/JFace just don't look very nice, compared to all the new Web 2.0 or Mac designs found in modern apps today.

What other features could be put into yet-another-twitter-client? Tag clouds? URL clouds? Charts? Google Maps? Automatic translations like Babelfish?

In-Memory Databases

Posted by Mike Haller on Tuesday, May 5. 2009 at 21:58 in Java
For testing and demo installation purposes, or for in-memory data aggregation operations, it may be suitable to use a "nearly full-blown" database. They're called in-memory databases and there are some implementation for the Java platform which are used since years:

hsqldb
One of the first 100% Java implementations of a SQL relational database management system. Like all the others, it can be run from a persistent file system or run in-memory. It's fast, it has a very low footprint and it can be embedded in any Java application. Hsqldb was my favourite for years to use in unit tests and integration tests. It can also read and write CSV files.

H2Database
The successor of hsqldb is H2. It's better documented, performs even better and has more options. There's even a web console where you can work with the data in the in-memory database like you can do with phpMyAdmin. Great thing. I'm currently using H2 at home and at work.

Derby
Derby, the Java database, now also supports the in-memory protocol. That's great to hear and an additional argument for switching to Derby as the default implementation for databases in embedded versions or for demo installations.

About

My name is Mike Haller and I'm a software developer and architect at Innovations Software Technology in Germany. I love programming, playing games and reading books. I like good food, making photos and learning and mentoring about the craftsmanship of commercial software development.

Quicksearch