code: def profileTM(tmClass, tmDim, nRuns):
    
  
    # create TM instance to measure
    tm = tmClass(numberOfCols=tmDim)
  
    # generate input data
    data = numpy.random.randint(0, 2, [tmDim, nRuns]).astype('float32')
  
    for i in xrange(nRuns):
      # new data every time, this is the worst case performance
      # real performance would be better, as the input data would not be completely random
      d = data[:,i]
  
      # the actual function to profile!
      tm.compute(d, True)
docs: profiling performance of TemporalMemory (TM)
    using the python cProfile module and ordered by cumulative time,
    see how to run on command-line above.
  
    @param tmClass implementation of TM (cpp, py, ..)
    @param tmDim number of columns in TM
    @param nRuns number of calls of the profiled code (epochs)