November 27, 2005

plan/b backup software

Just stumbled on planb when browsing on the ActiveMq site.
To quote the site :
"Plan/B is a network aware file backup system specifically designed to make the backup of files from multiple machines to a variety of devices simple."

This is exactly the concept I had in mind as a backup system for myself and since I couldn't find one, I was planning on writing a javabased backup system myself.
As far as I can see it is free, but it is not clear if it will stay that way. The one thing that is missing is some kind of API to write extensions (although I might just have missed that).

Posted by mvdb at 02:50 PM | Comments (0)

November 25, 2005

JavaPolis, who else is coming?

Just registered for javapolis for the whole week :) I am not going to conferences a lot, but since this is affordable, not too far a drive (about 30 minutes) and has some very nice topics.
I already scheduled with Martin Marinschek (MyFaces) to have some drinks, hope to meet James Strachan again, Vincent Massol and I just read Milos Kleint (mevenide) is also going to be presenting there.
If you are going to be there and like to meet up, let me know.. (mail me at feest at mvdb.net or leave a comment).
For people who don't know who I am (it is not a secret, but also not specifically mentioned on the website) : I am Martin van den Bemt..

If you are in a big emergency of finding a place to stay, you can stay at my place (I live in The Netherlands, about 30 minutes from Antwerp)
If you are frightened of cats (or allergic), you better find some other place to bunk..

Posted by mvdb at 11:35 PM | Comments (0)

November 21, 2005

Weird String code

String String = "String";
String = new String(String);

Pretty confusing if you give this to a java beginner :)

Posted by mvdb at 06:56 PM | Comments (3)

November 19, 2005

Timing differences in Systems nanoTime and Milliseconds

I often write preformance test for small code snippets to figure out what the, at least in my eyes, is the best and fasted code.
One example is checking to see if overall NIO file access is faster for my scenerio, instead of non nio based file access. Or how expensive method calls are, compared to direct instance variable access. I have a timertestcase which I use for timing how long a method is running. The problem is that one time something takes 50 ms another time 10 ms and again another time it takes 80 ms (even doing non file based things). So I thought it would be nice to check out the jdk 1.5 System.nanoTime(). I created the test (see below) and to my surprise, nanoTime actually gives better time feedback than System.currentTimeMillis. The testscenario is setting registring the starttime, sleep for 55 ms and registring the stoptime. This should end up with about 55.
I am looping 50 times.
System.currentTimeMillis has 0 hits on 55 ms and minimum was 46 ms and the maximum was 63, although this gives you an average of 54,5.
System.nanoTime() has 49 hits on 55 ms and one miss at 63.

Don't know what to think of this though. Just in case someone is intersted : the test was run on Windows XP sp 2, P4 3.0Ghz, with 1 gig of RAM, and the test was run from eclipse.

Here is the code... Curious about the result of others.. It's not a contest for nice coding practices though :)


long start = 0;
long stop = 0;
int correctMs = 0;
long maxValue = 0;
long minValue = -1;
long total = 0;
for (int i = 0; i < 50; i++) {
  start = System.currentTimeMillis();
  Thread.sleep(55);
  stop = System.currentTimeMillis();
  total = stop -start;
  if (total == 55) {
    correctMs++;
  } else {
    if (total > maxValue) maxValue = total;
    if (total < minValue || minValue == -1) minValue = total;
  }

}
System.out.println("Correct ms : " + correctMs);
System.out.println("min : " + minValue);
System.out.println("max : " + maxValue);
int correctNs = 0;
maxValue = 0;
minValue = -1;
for (int i = 0; i < 50; i++) {
  start = System.nanoTime();
  Thread.sleep(55);
  stop = System.nanoTime();
  total = ((stop - start) / 1000000);
  if (total == 55) {
     correctNs++;
  } else {
     if (total > maxValue) maxValue = total;
     if (total < minValue || minValue == -1) minValue = total;
   }
}
System.out.println("Correct ms : " + correctNs);
System.out.println("min : " + minValue);
System.out.println("max : " + maxValue);

Update : Sam Pullara gave me a fix for the code (already changed above) and noted that commenting wasn't working, which is fixed again Thanx. Sam.
He also gave me the results from above for the MacOS and there was less difference between the 2 methods than on my machine :
Correct ms : 48
min : 56
max : 56
Correct ms : 47
min : 54
max : 54

Posted by mvdb at 04:19 PM | Comments (1)

Sometimes I just want to be a user

One minute I am sick and tired of open source and the other minute I am going at it again.
One of my biggest reasons to ignore opensource for a while, is that using opensource can be a real productivity killer for me.
To help me achieve something in my software, I "stumble" on a certain project that can help me in that effort. I start using that package and a at a certain stage I hit a bug or lack of functionaly to be expected from a piece of code (this is almost a rule, not an exception for me), you checkout the source to see if the latest is doing a better job and if not you start fixing it. So now you have to get familiar with the people behind the project, coding style, making tests and praying your patch actually gets applied. If this happens a bit too often, you get so distracted from your actual goals, that you don't have much time left to do the real work.
At a certain stage you are so sick and tired of fixing things, waiting to get things patched that you just don't bother anymore, or you just fork the code and happily fix it there and not contributing back anymore. At a certain stage you will have a go at it again and the process starts over.

Let me make clear that I love opensource and absolutely don't want to work without it, so this is not a specific opensource problem, since I hit a lot of bugs in commercial software too, but it's kind of hard to fix stuff (or figure out why it is broken) if you don't have the source :)

I wish I could be more of a user for the software I use, without feeling I am a tester, debugger and possibly a fixer for everything I use or at least try to find a nice balance.
Won't care about the balance if doing this kind of thing was actually also in my job description.

Posted by mvdb at 11:54 AM | Comments (0)