ptolemy.actor.lib
Class ExecutionTime
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.Source
ptolemy.actor.lib.LimitedFiringSource
ptolemy.actor.lib.ExecutionTime
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
public class ExecutionTime
- extends LimitedFiringSource
Read the input token, if there is one, execute an (uninteresting)
computation to consume a specified amount of real time or to execute
it a fixed number of times, and produce
on the output the actual execution time (in milliseconds). Unlike the
Sleep actor, which suspends the calling thread for the specified
amount of time, this actor performs a computation during the
specified amount of time, thus consuming compute resources.
If realTime is true, then the number of computations it
performs is not fixed, but rather depends on what the thread
scheduler does. If it is false, then the amount of computation
done is fixed. The default is false.
- Since:
- Ptolemy II 8.0
- Version:
- $Id: ExecutionTime.java 57044 2010-01-27 22:41:05Z cxh $
- Author:
- Edward A. Lee
- See Also:
Sleep
,
Serialized Form
- Accepted Rating:
- Proposed Rating:
Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Method Summary |
void |
fire()
Read the input token, consume time, the produce on the
output the actual execution time used. |
Methods inherited from class ptolemy.actor.AtomicActor |
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup |
Methods inherited from class ptolemy.kernel.ComponentEntity |
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName |
Methods inherited from class ptolemy.kernel.Entity |
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName |
Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
executionTime
public Parameter executionTime
- The amount of time to consume. This is either in milliseconds,
if the realTime parameter is set to true, or in the number of
iterations of a fixed computation, if the realTime parameter
is set to false. This is a long
that defaults to 1000L.
granularity
public Parameter granularity
- The granularity of the computation. This parameter specifies
the number of additions performed in each invocation of the
(unintersting) computation. This is a long, which defaults
to 400000, which yields a computation time granularity
of approximately 1msec on a MacBook Pro.
realTime
public Parameter realTime
- If true, then the executionTime parameter is
interpreted as milliseconds. If it is false (the default), then the
executionTime parameter is interpreted to specify the number
of cycles of a fixed computation. Use false to specify
a fixed computational load, and use true to specify an
amount of real time to consume. When this is true,
if the thread executing the fire() method is preempted
during its run, then less computation is done.
ExecutionTime
public ExecutionTime(CompositeEntity container,
java.lang.String name)
throws NameDuplicationException,
IllegalActionException
- Construct an actor with the given container and name.
- Parameters:
container
- The container.name
- The name of this actor.
- Throws:
IllegalActionException
- If the actor cannot be contained
by the proposed container.
NameDuplicationException
- If the container already has an
actor with this name.
fire
public void fire()
throws IllegalActionException
- Read the input token, consume time, the produce on the
output the actual execution time used.
- Specified by:
fire
in interface Executable
- Overrides:
fire
in class Source
- Throws:
IllegalActionException
- If send() throws it.