0

私は画像検索システムに取り組んでいます。CBIR のパフォーマンスを評価するために、検索時間を計算する必要があります。組み込み機能の tic および toc 関数を使用しました。実行ごとに異なる時間が表示されるのを確認し、実行から実行までの時間を合計する時間も見ました。たとえば、取得時間を保存するなど、取得ごとに取得時間を計算しようと多くのことを行いました (つまり、 toc を含む) 1 つの変数で timeR=toc と言うと、次の検索では timeR=0 になります...

timeR=o;
tic;

% image retrieval process

toc;

timR=toc;

それでも私は異なる時間を取得します..各クエリ画像の取得時間を計算する方法について誰か助けてください、ありがとう

4

1 に答える 1

1

取得のコードは、画像ごとにわずかに異なる場合があります。実行時間をよりよく理解するには、Matlab のプロファイリング ツールを使用することをお勧めします。

 profile clear;
 profile on; 
 % your code here
 profile off;
 profile viewer;

プロファイラーを使用すると、コードで何が時間がかかるかを確認できます。

さらに、コード スニペットでtoc2 回呼び出すと、発生している奇妙な動作が発生する可能性があります。

より具体的な対策については、試してみてください

rTimes = zeros(1, numMethods);
% prepare images and what ever you need ...
for imi = 1:numImages
    % read test image ...
    tic;
    % use your method for ret.
    rTimes(1) = rTimes(1) + toc; % add this run time to your counter


    tic;
    % here you run method 2 that you want to compare to...
    rTimes(2) = rTimes(2) + toc; % add run time for method 2

    % do the same for all methods ...

    tic;
    % run the numMethods-th method
    rTimes(numMethods) = rTimes(numMethods) + toc;
end
% now rTimes hold the running times (overall) for all methods over all test images.
于 2012-11-24T20:23:39.320 に答える