Debug opencv_imgcodecs490d.dll is very slow

My final solution: build opencv using the following parameters in CMAKE_C_FLAGS_DEBUG и CMAKE_CXX_FLAGS_DEBUG:

/Zi /Ob2 /O2 /MD