Main Content

target.Timer クラス

名前空間: target

プロセッサのタイマーの詳細を提供する

R2020b 以降

説明

target.Timer クラスを使用して、プロセッサのタイマーの詳細を提供します。たとえば、C または C++ 関数のインターフェイスと実装、周波数、タイマーのカウント方向に関する情報などです。プロファイリング用に C または C++ コードのインストルメント化に関する情報を提供するために、タイマーの詳細を target.Processor オブジェクトと関連付けることができます。

target.Timer オブジェクトの作成には関数 target.create を使用します。オブジェクトを作成してから、別のステップを使用してプロパティを指定します。または、名前と値の引数を使用して、オブジェクトの作成とプロパティの指定を単一のステップで行います。

プロパティ

すべて展開する

タイマーの名前。

属性:

GetAccess
public
SetAccess
public

タイマーのカウント方向。

属性:

GetAccess
public
SetAccess
public

API 実装に関する情報。現在の時間を判断するために使用されます。

名前と値の引数を使用して target.Timer オブジェクトを作成する場合、APIImplementation プロパティに対し、以下の引数を指定します。

名前説明
'FunctionName'必須。target.Function オブジェクトの Name プロパティ。
'FunctionReturnType'必須。target.Function オブジェクトの ReturnType プロパティ。
'IncludeFiles'必須。target.BuildDependencies オブジェクトの IncludeFiles プロパティ。
'FunctionLanguage'オプション。target.API オブジェクトの Language プロパティ。
'SourceFiles' オプション。target.BuildDependencies オブジェクトの SourceFiles プロパティ。
'IncludePaths'オプション。target.BuildDependencies オブジェクトの IncludePaths プロパティ。

属性:

GetAccess
public
SetAccess
public

タイマー関数によって返される単位の周波数。この値は、タイマー関数の出力を秒単位に変換するために使用できます。ヘルパー クラス target.unit.Frequency には、いくつかの共通する周波数単位が含まれます。

属性:

GetAccess
public
SetAccess
public

データ型: uint64

すべて折りたたむ

開発用コンピューター向けの timer オブジェクトを作成します。

タイマーの関数シグネチャを作成します。この例では、関数は uint64 データ型と関数名 timestamp_x86 を返します。

timerSignature = target.create('Function');
timerSignature.Name = 'timestamp_x86';
timerSignature.ReturnType = 'uint64';

API オブジェクト内の関数を取得します。

timerApi = target.create('API');
timerApi.Functions = timerSignature;
timerApi.Language = target.Language.C;
timerApi.Name = 'Linux Timer API';

関数の依存関係、つまり関数を実行するために必要なソース ファイルとヘッダー ファイルを取得します。

timerDependencies = target.create('BuildDependencies');
timerDependencies.IncludeFiles = {'host_timer_x86.h'};
timerDependencies.IncludePaths = ...
               {'$(MATLAB_ROOT)/toolbox/coder/profile/src'};
timerDependencies.SourceFiles = {'host_timer_x86.c'};

API と依存関係を組み合わせるオブジェクトを作成します。

timerImplementation = target.create('APIImplementation');
timerImplementation.API = timerApi;
timerImplementation.BuildDependencies = timerDependencies;
timerImplementation.Name = 'Linux Timer Implementation';

timer オブジェクトを作成してタイマー情報に関連付けます。

timer = target.create('Timer');
timer.APIImplementation = timerImplementation;
timer.Name = 'Linux Timer';

メモ

名前と値の引数を使用して、次のコマンドで timer オブジェクトを作成できます。

 timer = target.create('Timer', 'Name', 'Linux Timer', ...
           'FunctionName', 'timestamp_x86', ...
           'FunctionReturnType', 'uint64', ...
           'FunctionLanguage', target.Language.C, ...
           'SourceFiles', {'host_timer_x86.c'}, ...
           'IncludeFiles', {'host_timer_x86.h'}, ...
           'IncludePaths', {'$(MATLAB_ROOT)/toolbox/coder/profile/src'})

タイマーとアドオンを processor オブジェクトに割り当てます。

processor = target.get('Processor', 'Intel-x86-64 (Linux 64)');
processor.Timers = timer;

既存の timer オブジェクトをコピーして、そのコピーの特定のプロパティ値を変更することにより、新しい timer オブジェクトを作成できます。

newTimer = target.create('Timer', ...
                         'Copy', 'Linux Timer', ...
                         'Name', 'NewTimerName', ...
                         'FunctionName', 'newFunctioName');

バージョン履歴

R2020b で導入