SMIL 1.1.1
Loading...
Searching...
No Matches
test and benchmark programs

Generalities

test and benchmark programs are built if the build process is configured to create the "test" build target. Two ways to do this :

  • add the option "--test" when configuring Smil with the script config-smil;
  • use ccmake to enable the option "BUILD_TEST".
Note
test and benchmark programs follow the naming convention : test_XXXX.cpp and bench_XXXX.cpp.

test programs

See below an example of test program (this example is in the dev-tools directory in the source tree : dev-tools/test_template.cpp).

Note the call to the function pathTestImage(). This function is defined in the header Smil-build.h. When you call this function, it will search for an image in the images directory of the source tree. If it doesn't find it there, it will try to get it in the images directory of Smil web server.

#include "DMorphoMeasures.hpp"
#include "Smil-build.h"
using namespace smil;
class TestErode : public TestCase
{
virtual void run()
{
char *path;
path = pathTestImage("gray/lena.png");
Image<UINT8> imIn(path);
Image<UINT8> ImOut(imIn);
path = pathTestImage("gray/lena-erode.png");
Image<UINT8> imTruth(path);
erode(imIn, imOut);
TEST_ASSERT(imOut == imTruth);
if (retVal != RES_OK)
imOut.printSelf();
}
};
class TestDilate : public TestCase
{
virtual void run()
{
char *path;
path = pathTestImage("gray/lena.png");
Image<UINT8> imIn(path);
Image<UINT8> ImOut(imIn);
path = pathTestImage("gray/lena-dilate.png");
Image<UINT8> imTruth(path);
dilate(imIn, imOut);
TEST_ASSERT(imOut == imTruth);
if (retVal != RES_OK)
imOut.printSelf();
}
};
int main()
{
TestSuite ts;
ADD_TEST(ts, TestErode);
ADD_TEST(ts, TestDilate);
return ts.run();
}
virtual void printSelf(ostream &os=std::cout, string s="") const
printSelf() -
Definition DGraph.hpp:578
Main Image class.
Definition DImage.hpp:57

There are two ways to launch the built test programs (in the build tree).

  1. launch all tests :
    make test
  2. launch a single test (as an example) :
    bin/test_hierar_queue

bench programs

See below an example of benchmark program (this example is in the dev-tools directory in the source tree : dev-tools/bench_template.cpp).

#include "Core/include/DCore.h"
#include "DMorpho.h"
using namespace smil;
int main()
{
Image<UINT8> im1(5562, 7949);
Image<UINT8> im2(im1);
UINT BENCH_NRUNS = 1E2;
BENCH_IMG_STR(dilate, "hSE", im1, im2, hSE());
BENCH_IMG_STR(dilate, "sSE", im1, im2, sSE());
BENCH_IMG_STR(dilate, "CrossSE", im1, im2, CrossSE());
BENCH_IMG_STR(open, "hSE", im1, im2, hSE());
BENCH_IMG_STR(open, "sSE", im1, im2, sSE());
BENCH_IMG_STR(open, "CrossSE", im1, im2, CrossSE());
}
Cross structuring element.
Definition DStructuringElement.h:470

There are two ways to launch the built benchmark programs (in the build tree).

  1. launch all benchmarks :
    for b in bin/bench*
    do
    printf "====== %-24s ======\n" $(basename $b)
    $b
    done
  2. launch a single benchmark (as an example) :
    bin/bench_hierar_queue