4.3 Measuring Custom Benchmark Program Performance

Once you've modified variables for your routine, action and instance names, it's time to measure the performance of your benchmarking program. In this section, we will not cover the details of how to write programs with HDF5 library since there are plenty of tutorial examples on The HDF Group web site. Rather, we'll focus on how to inject your HDF5 program into our tutorial example.

Adding your own program into HPF is as simple as putting a letter into an envelop. All you have to do is to insert your own program between two API pairs called H5Perf_startTimer() and H5Perf_endTimer(). In the write.c example that we used in the previous subsection, look for the above APIs near line 110. It'll look like below program listing:

  H5Perf_startTimer(& start);
  
  /* BEGIN: Insert your custom benchmark program here */
  status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
		    H5P_DEFAULT, data);
  /* END */
  
  time_used = H5Perf_endTimer(start);

In the above example, you're measuring the "H5Dwrite" performance of writing "data" which is initialized at the beginning of the write.c file:

  /*
   * Data and output buffer initialization.
   */
  data = (int*)malloc(sizeof(int)*dx*dy);
  tempdata = data;
    
  for (j = 0; j < dy; j++) {
    for (i = 0; i < dx; i++){
      *tempdata = i + j;
      tempdata++;
    }
  }

As you can see, the "data" initialization is not a part of performance measurement and is done at the beginning of the program. It is important to wrap only the target HDF5 API function(s) when measuring the performance. Don't wrap around other parts of source code since those code may take long time and it may affect the benchmark results accordingly. In our example programs, irrelevant parts like HDF5 file creation are always outside of the two wrapper HPF APIs -- H5Perf_startTimer() and H5Perf_endTiemr().