ptolemy.actor.lib
Class ExecutionTime

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.actor.AtomicActor
                      extended by ptolemy.actor.TypedAtomicActor
                          extended by ptolemy.actor.lib.Source
                              extended by ptolemy.actor.lib.LimitedFiringSource
                                  extended by 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:
Red (cxh)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
 Parameter executionTime
          The amount of time to consume.
 Parameter granularity
          The granularity of the computation.
 Parameter realTime
          If true, then the executionTime parameter is interpreted as milliseconds.
 
Fields inherited from class ptolemy.actor.lib.LimitedFiringSource
_firingCountLimit, _iterationCount, firingCountLimit
 
Fields inherited from class ptolemy.actor.lib.Source
output, trigger
 
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
ExecutionTime(CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
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.lib.LimitedFiringSource
attributeChanged, initialize, postfire
 
Methods inherited from class ptolemy.actor.lib.Source
prefire
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints
 
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.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 
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
 
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

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.

Constructor Detail

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.
Method Detail

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.