# mmbench
benchmarking main functions of the toolbox.

## Synopsis

mmbench( count = 10 )

Implemented in Python.

### Input

count | Double Number of repetitions of each function. Default: `10`

## Description

mmbench measures the speed of many of SDC Morphology Toolbox functions in seconds. An illustrative example of the output of mmbench is, for a MS-Windows 2000 Pentium 4, 2.4GHz, 533MHz system bus, machine:

    SDC Morphology Toolbox V1.2 27Sep02 Benchmark
    Made on  Wed Jul 16 15:33:17 2003  computer= win32
    image filename= csample.jpg  width= 640 , height= 480
        Function                            time (sec.)
     1. Union  bin                       0.00939999818802
     2. Union  gray-scale                0.00319999456406
     3. Dilation  bin, mmsecross         0.0110000014305
     4. Dilation  gray, mmsecross        0.00780000686646
     5. Dilation  gray, non-flat 3x3 SE  0.0125
     6. Open      bin, mmsecross         0.0125
     7. Open      gray-scale, mmsecross  0.0141000032425
     8. Open      gray, non-flat 3x3 SE  0.0235000014305
     9. Distance  mmsecross              0.021899998188
    10. Distance  Euclidean              0.0264999985695
    11. Geodesic distance mmsecross      0.028100001812
    12. Geodesic distance Euclidean      0.303100001812
    13. Area open bin                    0.0639999985695
    14. Area open gray-scale             0.148500001431
    15. Label mmsecross                  0.071899998188
    16. Regional maximum, mmsecross      0.043700003624
    17. Open by rec, gray, mmsecross     0.0515000104904
    18. ASF by rec, oc, mmsecross, 1     0.090600001812
    19. Gradient, gray-scale, mmsecross  0.0171999931335
    20. Thinning                         0.0984999895096
    21. Watershed                        0.268799996376
        Average                          0.0632523809161

## Source Code

    def mmbench(count=10):
        from sys import platform
        from time import time, asctime
        from Numeric import average, zeros
        filename = 'csample.jpg'
        f = mmreadgray(filename)
        fbin=mmthreshad(f,150)
        se = mmimg2se(mmbinary([[0,1,0],[1,1,1],[0,1,0]]),'NON-FLAT',int32([[0,1,0],[1,2,1],[0,1,0]]))
        m=mmthin(fbin)
        tasks=[
           [' 1. Union  bin                      ','mmunion(fbin,fbin)'],
           [' 2. Union  gray-scale               ','mmunion(f,f)'],
           [' 3. Dilation  bin, mmsecross        ','mmdil(fbin)'],
           [' 4. Dilation  gray, mmsecross       ','mmdil(f)'],
           [' 5. Dilation  gray, non-flat 3x3 SE ','mmdil(f,se)'],
           [' 6. Open      bin, mmsecross        ','mmopen(fbin)'],
           [' 7. Open      gray-scale, mmsecross ','mmopen(f)'],
           [' 8. Open      gray, non-flat 3x3 SE ','mmopen(f,se)'],
           [' 9. Distance  mmsecross             ','mmdist(fbin)'],
           ['10. Distance  Euclidean             ','mmdist(fbin,mmsebox(),"euclidean")'],
           ['11. Geodesic distance mmsecross     ','mmgdist(fbin,m)'],
           ['12. Geodesic distance Euclidean     ','mmgdist(fbin,m,mmsebox(),"euclidean")'],
           ['13. Area open bin                   ','mmareaopen(fbin,100)'],
           ['14. Area open gray-scale            ','mmareaopen(f,100)'],
           ['15. Label mmsecross                 ','mmlabel(fbin)'],
           ['16. Regional maximum, mmsecross     ','mmregmax(f)'],
           ['17. Open by rec, gray, mmsecross    ','mmopenrec(f)'],
           ['18. ASF by rec, oc, mmsecross, 1    ','mmasfrec(f)'],
           ['19. Gradient, gray-scale, mmsecross ','mmgradm(f)'],
           ['20. Thinning                        ','mmthin(fbin)'],
           ['21. Watershed                       ','mmcwatershed(f,fbin)']]
        result = zeros((21),'d')
        for t in range(len(tasks)):
           print tasks[t][0],tasks[t][1]
           t1=time()
           for k in range(count):
              a=eval(tasks[t][1])
           t2=time()
           result[t]= (t2-t1)/(count+0.0)
        print mmversion() +' Benchmark'
        print 'Made on ',asctime(),' computer=',platform
        print 'image filename=',filename,' width=', f.shape[1],', height=',f.shape[0]
        print '    Function                            time (sec.)'
        for j in range(21):
         print tasks[j][0], result[j]
        print '    Average                         ', average(result)
        out=[]

[`mmversion`] [Up] [`mminstall`] |
Copyright (c) 2003, Roberto A. Lotufo, UNICAMP-University of Campinas; Rubens C. Machado, CenPRA-Renato Archer Research Center.