Java

Archived Posts from this Category

Eep

Posted by Kevin Powe on 13 Mar 2008 | Tagged as: Java, Nerd Thoughts

Two months since a post? Good lord.

Work has been mad, combined with pressure building on writing my convention game for July.

But I do indeed have a post brewing – I’d gone and written up a blog post on the weekend regarding the Google Chart API, and then I go and run into jMaki, which changes a few things significantly. I’m starting to play with it at the moment, and it already provides a wrapper over the Google Charting API. (road testing it will see how much easier it makes things…)

Other than that, my Western genre immersion continues.

So, meaningful updates shortly. In the meantime, I have indeed implemented a script to show my current headspace – you can see it in action here. It uses an ImageCache PHP script that I did indeed end up writing as promised in a previous post, along with a wrapper over the Google Charting API. It’s driven off a database table, and the next step (which I’ll plug jMaki in for, as opposed to developing another custom wrapper over bar charts) is to get it to graph the rise and fall of particular items over time.

Delicious, delicious data! We loves it so!

Oh, and while Ajax does some tremendous things in providing a rich, lightweight interface via a web client, I’d argue that good old SQL is still one of the most powerful, important tools to business, and for finding Truth.

How to verify Java VM timer precision

Posted by Kevin Powe on 02 Dec 2007 | Tagged as: Gobbledygook, Java

I recently had need to verify the precision of the Java VM’s timing precision on various platforms. We were doing some rough benchmarking of ALBPM and ALSB, and needed to measure how long individual processing steps were taking. We got some results that seemed flakey from log4j messages, hence arriving at wondering about JVM timing precision.

I found a simple and elegant solution at YIP Chi Lap’s HK University site. One of those solutions you smack yourself in the head (or *facepalm*, if you roll with the IM kids) for not thinking of yourself. The Java application goes into a tight loop, printing the difference between the current time in milliseconds and the starting time that the app gets before going into a tight loop. It’s pretty short, so here’s the code:


public class TimerTest
{
  public static void main(String[] args)
  {
    long base=System.currentTimeMillis();
    for (int r=0; r<1000; ++r)
    {
      System.out.print(System.currentTimeMillis()-base);
      System.out.print(' ');
     }
  }
}

Because no solution is complete without shell scripting, I ran the output through uniq after modifying the .print statement to a .println. That made the output a little clearer.

To make the solution a one stop shop, I’ve created a slightly modified version of the Java class which only outputs unique timing results (essentially doing the job of uniq) It’s a small modification, but it makes the output less chatty and more manageable. Definitely a class that’s going in my tool belt.