Best Practices for Calling Imatest IT Libraries
Only run in a single thread
The MATLAB runtime library does not support multiple threads using the same library.
For high speed parallel testing Imatest IT Parallel can use multiple processes to increase testing throughput up to three times. As of 5.1 ITP is now rolled in to IT.
Only initialize a single time for multiple runs
Initializing the library has significant computational cost. and the first call made to the library will run slower than subsequent runs.
The library should remain initialized throughout the life cycle of the calling program that should have reasonable longevity of its own.
mclTerminateApplication() or terminate() must be called once only per process
Calling mclTerminateApplication (C/C++) or terminate (Python) more than once may cause your application to exhibit unpredictable or undesirable behavior.
Do not use busy waiting while analysis runs
A main tester program that invokes a separate tester program should not use busy waiting or spinlocks to wait for the analysis to be completed.
Pass images directly instead of writing to disk
Use the direct passing of images in order to avoid having to write files to disk, only for them to be immediately read back by Imatest IT.
The availability of high speed SSD and HDD caches may reduce the expense of repeatedly writing and reading from disk, but have other risks associated with them and
Use analysis modules that combine tests
SFRplus and eSFR ISO perform many different calculations on a single image. These modules will always perform better
For SFR tests, use multiple regions on a single image
Multiple region selections allow a single module to test multiple points on the image. If you are cannot use the combined anaysis modules mentioned above, and are forced to use SFR for sharpness tests, make sure to use the multiple region selection.
Set the MCR_CACHE_ROOT and MCR_CACHE_SIZE environment variables
To substantially reduce startup times of IT/DLL and IT/EXE call, create and set the MCR_CACHE_ROOT
environment variable to a folder for which the user has read/write access, and the MCR_CACHE_SIZE
environment variable to a value of 900000000 or higher. When these environment variables are set, the lengthy decompression stage that happens during IT initialization results in the data being stored in the MCR_CACHE_ROOT
folder, instead of a temporary directory that is deleted after IT exits. If the relevant decompressed data is already present in MCR_CACHE_ROOT
, then the decompression stage is skipped and substantial time is saved (~10s).
Example:
For Windows Vista and above:
To permanently set this environment variable you can use the setx command. Open a command window and enter the following (substitute the folder path with your desired path)
setx /m MCR_CACHE_ROOT "C:\Users\<this_user>\My Documents\MCR_Cache"
setx /m MCR_CACHE_SIZE "900000000"
Note the ‘/m’ indicates that the variable will be defined for all users and that the new environment variable is only available after the command window is closed.
For Windows XP, please follow Microsoft’s instructions for setting environment variables.
For Linux:
To make MCR_CACHE_ROOT and MCR_CACHE_SIZE available for all users, append its definition to either /etc/environment
or /etc/profile
.
MCR_CACHE_ROOT="/home/<this_user>/Documents/MCR_Cache"
MCR_CACHE_SIZE=900000000
Otherwise, modify the ~/.profile
or ~/.bashrc
files to append the definition.
export MCR_CACHE_ROOT=/home/<this_user>/Documents/MCR_Cache
export MCR_CACHE_SIZE=900000000
Throw hardware at the problem
When software configuration changes cannot give adequate speed improvements, utilizing computing hardware with faster clock speeds and more processor cores is the brute force way of increasing performance.