LabPal Run experiments on a computer

Easily run experiments on a computer

If you are doing research in Computer Science, it is very likely that every now and then, you need to run experiments on your computer. LabPal is a Java library that allows you to quickly setup an environment for running these experiments, collating their results and processing them in various ways: generating tables, data files, plots, etc.


All these features are available in less than 30 lines of Java code. See the example below!

Why use LabPal?

To run experiments on a computer, you probably already write command-line scripts for various tasks: generating your data, saving it into text files, process and display them as plots or tables to include in a paper or a presentation. But soon enough, your handful of "quick and dirty" batch files becomes a bunch of arcane, poorly documented scripts that generate and pass around various kinds of obscure temporary files. This situation brings two important problems in terms of research methodology:

Learn LabPal in five minutes

LabPal is easy enough to use that you can get up and running in a couple of minutes. Below is a minimal, but complete set of experiments for LabPal in less than 30 lines of code:

class MyLaboratory extends Laboratory {

  public void setup() {
    ExperimentTable t = new ExperimentTable("Number", "Time");
    for (long n : new long[]{22602052667l, 42602051897l,
      63612552733l, 84612554431l})
      add(new MyExperiment(n), t);
    add(t).add(new Scatterplot(t));

  class MyExperiment extends Experiment {
    public MyExperiment(long n) {
      setInput("Number", n);
    public void execute() {
      BigInteger n = new BigInteger(Long.toString(readLong("Number")));
      long start = System.nanoTime();
      boolean b = n.isProbablePrime(1);
      long end = System.nanoTime();
      write("Time", end - start);
  public static void main(String[] args) {
    initialize(args, MyLaboratory.class);

In a nutshell:

What do we get in exchange for these 30 lines of code? Compile and run this file using the --web command-line argument. You should see a message telling you to visit http://localhost:21212/index in your browser.

If you go there, you'll see something like this:

Home page

The web interface contains a few pages, which you can access through the buttons at the top. Go to the Experiments page; there you see the list of the experiments that have been added to the lab, with the "Number" parameter that was assigned to each. The "thumbs up" icon indicates that they are ready to run.

Experiments page

Select them all by clicking on the topmost checkbox, and then click on the Add to queue button at the bottom. You have now put these experiments in the queue, waiting to be executed. Now visit the Lab assistant page: this is where you manage this queue.

Assistant page

Click on Start the assistant to launch the batch execution of all the experiments you selected. These experiments run very quickly; if you go to the to the Status page, you'll see that they are all done:

Status page

The experiments have produced results, which we have put in a table. Go to the Tables page, and click on the (only) table you see there, called "Table 1". There you see the results of the experiments:

Table page

In the tables page, note that you can also export the contents of that table in various formats (HTML, CSV, and LaTeX).

Finally, go to the Plots page to see the plot that has been created from that table:

Plots page

You see the plot that was created; click on it to view it full size. You can also export the plot as a PDF file; a button at the top also offers you the option to bundle all the available plots into a single, multi-page PDF.

That's it! Or not...

These are just some of the features you get for writing these 30 lines of code. Among other things you get for free:

I want to use LabPal!

If you want to know more about LabPal's features:

About LabPal

LabPal was developed by Sylvain Hallé, Associate Processor at Université du Québec à Chicoutimi, Canada. Pr. Hallé is also the head of LIF, a research lab where LabPal is extensively used for the processing of experimental results.