Search Results for

    Show / Hide Table of Contents

    Class PerformanceTrackerForLayoutAlgorithms

    Tracing performance on a large UI project is almost impossible using Unity's tools - they are too simplistic.

    TEMPORARY CLASS WHILE ADDING SOME SUBTLE PERFORMANCE IMPROVEMENTS

    The most basic performance work needs something that can track "for each invocation of each method, what parameters did it have, and were they unique?" - which Unity hasn't achieved yet. This class provides a way to track that information, and couple it with "what are the hotspots in our code -- where did the hot methods GET CALLED FROM?"

    This is a MUCH, MUCH simpler system than the HierarchicalLog / NinjaTreeLog (which records EVERYTHING and is a much faster alternative to Unity's built-in logging). This is ONLY designed to capture the most important, critical calls that are semantically important in FlexBuilder (e.g. 'size of item', 'size of container', etc).

    Usage:

    1. The LayoutAlgorithm has to support it internally - critical calls have to be decorated with calls to ".liveLog.StartMethod()" and "... .liveLog.EndMethod()"
    2. Make sure the log is enabled! ".isEnabled = true" -- by default it is ALWAYS DISABLED to preserve performance in non-debugging situations.
    3. At runtime, call .liveLog.Wipe() (to clear out any cached/previous perf data)
    4. At runtime, perform your FlexBuilder layout
    5. At rutnime, call .liveLog.Output
    Inheritance
    Object
    PerformanceTrackerForLayoutAlgorithms
    Namespace: NinjaTools.FlexBuilder.LayoutAlgorithms
    Assembly: cs.temp.dll.dll
    Syntax
    public class PerformanceTrackerForLayoutAlgorithms

    Fields

    - (Dictionary<Int32, Int64>) currentMethodKeys

    - (Boolean) isEnabled

    - (List<PerformanceTrackerForLayoutAlgorithms.PerformanceTrackerHotMethod>) measures

    Properties

    - (PerformanceTrackerForLayoutAlgorithms) layoutAlgorithmsLog

    - (PerformanceTrackerForLayoutAlgorithms) treeAlgorithmsLog

    Methods

    - (void) EndMethod(Int32, String, BFlexComponent, List)

    Inject this at the end of a Hot method you want to track.

    Parameters
    Int32 key

    The key that you were given when you called StartMethod

    String methodName

    The name of the method (should be hardcoded at source)

    BFlexComponent source

    The object that contains the method

    List<String> p

    - (void) EndMethod_AutoStackTrace(Int32, BFlexComponent, List, List)

    Like EndMethod(Int32, String, BFlexComponent, List<String>) except uses C#'s internal data to pre-fill the info AND to add contextual info about the call-site / caller / call-chain. NOTE: THIS IS MUCH MORE EXPENSIVE IN EXECUTION TIME, IT WILL SLOW DOWN YOUR CODE BY 10x OR EVEN UP TO 100x -- DO NOT USE EXCEPT TEMPORARILY OR BEHIND A #if !

    HOWEVER this will automatically early-out if this class isEnabled is set to false - so it is SAFE to leave compiled-in to a class you may want to performance-query later.

    Parameters
    Int32 key
    BFlexComponent source
    List<Int32> ancestorFrameIndices
    List<String> extraParams

    - (void) Output(PerformanceTrackerForLayoutAlgorithms.OutputMode, Func)

    Main output method - outputs directly to the Unity Console, optionally either "1 line for every measured item" or "1 single message containing ALL measured items, in CSV format ready for import to MS Excel", or both.

    Parameters
    PerformanceTrackerForLayoutAlgorithms.OutputMode oMode

    1 line, many lines, or both

    Func<BFlexComponent, String, Int32, Boolean> includeMethod

    Filter: if this is null, everything is included; otherwise only things that return true when pushed into this are included in the output

    - (Int32) StartMethod()

    Call this inside any decorated method you want to track; it provides a MagicKey that you pass-in to EndMethod(Int32, String, BFlexComponent, List<String>) or EndMethod_AutoStackTrace(Int32, BFlexComponent, List<Int32>, List<String>) at the end of the decorated method (it uses that to efficiently track that you're in the same branch of code / code-block)

    Returns
    Int32

    Magic key you should pass-in to a later EndMethod..(...) call

    - (void) Wipe()

    Resets the data - MUST be called before any new run, or else you'll get the polluted/corrupted data of multiple runs merged together

    In This Article
    Back to top http://flexbuilder.ninja