target.Timer Class
Namespace: target
Description
Use the target.Timer
class to provide timer details for your processor.
For example, information about the C or C++ function interface and implementation, frequency,
and timer count direction. To provide information about instrumenting C or C++ code for
profiling, you can associate the timer details with a target.Processor
object.
To create a target.Timer
object, use the target.create
function. Create the object and then use separate steps to specify
properties. Or, using name-value arguments, create the object and specify properties in a
single step.
Properties
Name
— Timer name
character vector | string
Name of timer.
Attributes:
GetAccess | public |
SetAccess | public |
Direction
— Count direction
'Up' | 'Down'
Direction of timer count.
Attributes:
GetAccess | public |
SetAccess | public |
APIImplementation
— API implementation
target.APIImplementation
object
Information about the API implementation, which is used to determine the current time.
If you use name-value arguments to create a target.Timer
object,
for the APIImplementation
property, specify these
arguments.
Name | Description |
---|---|
'FunctionName' | Required. Name property of
target.Function object. |
'FunctionReturnType' | Required. ReturnType property of
target.Function object. |
'IncludeFiles' | Required. IncludeFiles property of
target.BuildDependencies object |
'FunctionLanguage' | Optional. Language property of
target.API object. |
'SourceFiles ' | Optional. SourceFiles property of
target.BuildDependencies object. |
'IncludePaths' | Optional. IncludePaths property of
target.BuildDependencies object |
Attributes:
GetAccess | public |
SetAccess | public |
Frequency
— Frequency
scalar
Frequency of the unit returned by the timer function. This value can be used to
convert timer function output to seconds. The helper class
target.unit.Frequency
contains some common frequency units.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: uint64
Examples
Create Timer Object
Create a timer object for your development computer.
Create the function signature for a timer. In this example, the function returns a uint64
data type and the function name timestamp_x86
.
timerSignature = target.create('Function'); timerSignature.Name = 'timestamp_x86'; timerSignature.ReturnType = 'uint64';
Capture the function in an API object.
timerApi = target.create('API'); timerApi.Functions = timerSignature; timerApi.Language = target.Language.C; timerApi.Name = 'Linux Timer API';
Capture the dependencies of the function, that is, the source and header files that are required to run the function.
timerDependencies = target.create('BuildDependencies'); timerDependencies.IncludeFiles = {'host_timer_x86.h'}; timerDependencies.IncludePaths = ... {'$(MATLAB_ROOT)/toolbox/coder/profile/src'}; timerDependencies.SourceFiles = {'host_timer_x86.c'};
Create an object that combines the API and dependencies.
timerImplementation = target.create('APIImplementation'); timerImplementation.API = timerApi; timerImplementation.BuildDependencies = timerDependencies; timerImplementation.Name = 'Linux Timer Implementation';
Create the timer object and associate it with the timer information.
timer = target.create('Timer'); timer.APIImplementation = timerImplementation; timer.Name = 'Linux Timer';
Note
Using name-value arguments, you can create the timer object with this command.
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'})
Assign the timer and add-ons to the processor object.
processor = target.get('Processor', 'Intel-x86-64 (Linux 64)'); processor.Timers = timer;
Create Timer Object by Modifying Existing Object
You can create a new timer object by copying an existing timer object and modifying specific property values of the copy.
newTimer = target.create('Timer', ... 'Copy', 'Linux Timer', ... 'Name', 'NewTimerName', ... 'FunctionName', 'newFunctioName');
Version History
Introduced in R2020b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)