Salut à tous!
Je me retrouve devant un comportement bien curieux de la vitesse d'execution de mon code. Je m'explique:
Ce bout de code s'execute en ~3 ms
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 for (int i = 1; i < magnitude_->height-1; ++i) { for (int j = 1; j < magnitude_->width-1; ++j) { currentMagnitude = magnitude_->imageData[srcOffset2+j]; val1 = static_cast <uchar_t> (magnitude_->imageData[i*magnitude_->widthStep+j+1]); val2 = static_cast <uchar_t> (magnitude_->imageData[i*magnitude_->widthStep+j-1]); int toto = j; if (( currentMagnitude < val1) || (currentMagnitude < val2) ) { toto = 1; } magnitude_->imageData[0] = toto; } }
Celui-ci en 1.6ms
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 for (int i = 1; i < magnitude_->height-1; ++i) { for (int j = 1; j < magnitude_->width-1; ++j) { currentMagnitude = magnitude_->imageData[srcOffset2+j]; val1 = static_cast <uchar_t> (magnitude_->imageData[i*magnitude_->widthStep+j+1]); val2 = static_cast <uchar_t> (magnitude_->imageData[i*magnitude_->widthStep+j-1]); int toto = j; magnitude_->imageData[0] = toto; } }
et celui-là en 1.8ms
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 for (int i = 1; i < magnitude_->height-1; ++i) { for (int j = 1; j < magnitude_->width-1; ++j) { currentMagnitude = magnitude_->imageData[srcOffset2+j]; val1 = static_cast <uchar_t> (magnitude_->imageData[i*magnitude_->widthStep+j+1]); val2 = static_cast <uchar_t> (magnitude_->imageData[i*magnitude_->widthStep+j-1]); int toto = j; if (( currentMagnitude < val1) || (currentMagnitude < val2) ) { toto = 1; } } }
Je cherche à comprendre d'où peut venir cette différence. Options du compilo? Je patauge.
Merci d'avance pour vos réponse!
Frantz
PS: Code compilé en utilisant visual studio 2008.
Partager