[Insight-users] Memory probe question

Nicholas Tustison ntustison at gmail.com
Mon Aug 9 20:22:07 EDT 2010


Hi Users,

I'm having difficulty getting the itkTimeAndMemoryProbeTest to function as expected on the Mac (10.6.4).  When I run it, I get the following output

[ntustison at d-172-25-171-180 Mon Aug 09 20:16:45] $ ./itkTimeAndMemoryProbeTest 
          Probe Tag    Starts    Stops           Memory (kB)
         1024KB Test           1            1                 0
          170KB Test           1            1                 0
            1KB Test           1            1                 0
           70KB Test           1            1                 0
          Probe Tag    Starts    Stops           Memory (kB)
        Release Test           1            1                 0
 The test has last 0.000205994s

However, based on the way the test is written, this would seemingly be incorrect.  At first I thought maybe I needed to recompile ITK and the test in Debug mode but the output was the same as for a Release mode build (albeit the times were different).  Any idea what I'm doing wrong?

Thanks,
Nick Tustison

Ps. For those who lack the energy to look it up but are still interested, below is a copy of the source

#include "itkTimeProbe.h"
#include "itkMemoryProbesCollectorBase.h"

#include <iostream>

int main(int argc,char* argv[])
{
  (void)argc;
  (void)argv;

  itk::TimeProbe timeProbe;
  itk::MemoryProbesCollectorBase memoryProbes;

  timeProbe.Start();

  memoryProbes.Start("1KB Test");
  char* foo = new char[1*1024];
  memoryProbes.Stop("1KB Test");

  memoryProbes.Start("70KB Test");
  char* foo2 = new char[70*1024];
  memoryProbes.Stop("70KB Test");

  memoryProbes.Start("170KB Test");
  char* foo3 = new char[170*1024];
  memoryProbes.Stop("170KB Test");

  memoryProbes.Start("1024KB Test");
  char* foo4 = new char[1024*1024];
  memoryProbes.Stop("1024KB Test");

  memoryProbes.Report( std::cout );
  memoryProbes.Clear();

  memoryProbes.Start("Release Test");
  delete[] foo;
  delete[] foo2;
  delete[] foo3;
  delete[] foo4;
  memoryProbes.Stop("Release Test");

  memoryProbes.Report( std::cout );

  timeProbe.Stop();
  std::cout<<" The test has last "<<timeProbe.GetMean()<<timeProbe.GetUnit()<<std::endl;

  return EXIT_SUCCESS;
}



More information about the Insight-users mailing list