nodesource/ah-processor.utils

Name: ah-processor.utils

Owner: NodeSource

Description: Utilities used by the ah-*.processor modules.

Created: 2017-03-13 10:42:02.0

Updated: 2017-03-13 10:51:49.0

Pushed: 2017-03-20 11:00:59.0

Homepage: null

Size: 1204

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

ah-processor.utils

Utilities used by the ah-*.processor modules.

Installation
npm install ah-processor.utils

Table of Contents generated with DocToc

API
idsTriggeredBy

Finds all ids of activities that are triggered by the given id. This function works recursive, i.e. any activity triggered by a child of the root activity is included as well.

For this to work, activities are assumed to be in the order that they were triggered. This can easily be achieved by simply sorting the activities by their init timestamp.

Parameters

Returns Set<number> the provided root id and all ids of activities triggered by it or any of it's children, grandchildren, etc.

oldestId

Finds the oldest activity of the ones supplied via the ids. We consider an activity older than another one if it's init timestamp is further in the past.

Any ids we can't find as in the activities are ignored.

Parameters

Returns Number the id of the oldest activity or null if no activity for any id was found

immediatelyBeforeId

Finds the activity of the ones supplied via the ids that initialized immediately before the one with the given id initialized.

Parameters

Returns Number the id that initialized immediately before the activity with id or null if no activity for any id was found

prettyNs

Prettifies the provided timestamp which is expected to be in nanoseconds.

Parameters

Returns Object<string, number> an object with an ms property which is the prettified version of the provided timestamp in milliseconds and ns, the originally passed timestamp.

safeGetVal

Safely extracts the val property from the object x.

Parameters

Returns any the val property if x was defined, otherwise null

safeFirstStamp

Safely gets the first time stamp of the given timestamps. If no timestamp is found, a time of 0 is returned.

Parameters

Returns Object the prettified first time stamp

firstNonZeroStamp

Finds the first stamp in the array of time stamp arrays that has a valid time stamp. If none is found it will return a zero time stamp.

Parameters

Returns Object prettified time stamp or prettyNs(0) if not found

uniqueUserFunctions

Identifies all user functions within the given functions, adds location and propertyPath strings and returns the result.

The propertyPath is deduced from the path array.

If a user function is found twice it will only be included once.

Parameters

Returns Array<Object> all user functions with the above mentioned details added

separateUserFunctions

Pulls user functions from all resources of the provided info and attaches them as the userFunctions property to the info object directly.

As a result, instead of having a userFunctions array on each resource we end up with just one on the info object.

Parameters

mergeUserFunctions

Merges the userFunctions found on the info object, such that all functions with the same location property are represented as one.

As the result the propertyPath array is removed from all functions and replaced with the propertyPaths array which combines the propertyPaths of all functions that matched the location.

Parameters

lifeCycle

Obtains the life cycle information using the init and destroy time stamps of the given activity.

All time stamps have the format: { ns: <time in naseconds>, ms: <pretty printed time> }

The return value includes the following properties:

Parameters

Returns Object the life cycle information

processActivities

Applies multiple processors to the given activities in order to process them into operations. Each activity that is identified as part of an operation is removed from the activities map, i.e. it is modified in place. Therefore any activities still present in the map after processing completes, couldn't be processed into an operation.

Each processor needs to be instantiable and have a process function that returns { groups, operations}. Additionally each processor needs to have the following static properties:

Parameters

Returns Array<Object> a collection of operations that were identified from the given activities

License

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.