Skip to content

FSharp API

Greg Young edited this page Aug 14, 2016 · 9 revisions

Private Eye F# API

The easiest way to see what various methods do is to look at privateeye.fsx

Here we enumerate the methods and explain what each does.

Utility Methods

This section covers the utility methods in PrivateEye such as connecting to a remote profiler or getting the status on the profiler.

addFsiPrinters()

Adds custom fsi printers into the fsi session. Without adding custom printers you will get the default behaviour of fsi for printing returned results.

Before

- mostCalledMethods();;
val it : seq<profilersession.MethodInformation> =
  seq
    [PrivateEye.Bridge.profilersession.MethodInformation;
     PrivateEye.Bridge.profilersession.MethodInformation;
     PrivateEye.Bridge.profilersession.MethodInformation;
     PrivateEye.Bridge.profilersession.MethodInformation; ...]

After

> mostCalledMethods();;
val it : seq<profilersession.MethodInformation> =

--------------------------------------------------------------------------------
|Name                             |  Called| Total Time|Allocs|  A. Size|Thrown|
--------------------------------------------------------------------------------
|ProcessBlock (byte[],int)        | 3176533| 16402.0126|     0|        0|     0|
|get_Chars (int)                  |  170507|   483.9711|     0|        0|     0|
|get_Rank ()                      |  140403|  2138.1667|     0|        0|     0|
|GetRank (System.Array)           |  140403|   915.1704|     0|        0|     0|
|get_Length ()                    |  131869|  2944.0053|     0|        0|     0|
|__icall_wrapper_mono_object_new_s|   81548|   922.2145| 81548|  3493132|     0|
|CachePropertyInfo (System.Reflect|   78383|   302.0055|     0|        0|     0|
|ReadSegment (byte[],int,int)     |   76117|   416.0591|     0|        0|     0|
|GetAttributeFlagsImpl ()         |   73713|   874.5466|     0|        0|     0|
|GetAttributes (System.RuntimeType|   73713|   291.3721|     0|        0|     0|
--------------------------------------------------------------------------------

connectTo(endPoint : IPEndPoint)

Connects to a listening profiler located at endPoint. You should see the TCP connection be accepted.

startListening()

Begins listening on the default IP/Port (127.0.0.1:4444) for incoming connections from a profiler.

startListeningOn(endPoint : IPEndPoint)

Begins listening on the IP/Port provided in the endpoint for incoming connections.

disconnect()

Disconnects the connected session (either from connectTo or via listen)

profilerStats()

Returns statistics on the profiler including how many messages and of what type have been processed.

getFilters()

Returns the effective filters for the profiler you are connected to.

Control Methods

addIncludeFilter(x : string)

Adds an include filter dynamically to the connected profiler instance. The string supports regexps.

removeIncludeFilter(x : string)

Removes an include filter dynamically fron the connected profiler instance. The string supports regexps.

addExcludeFilter(x : string)

Adds an exclude filter dynamically to the connected profiler instance. The string supports regexps.

removeExcludeFilter(x : string)

Removes an exclude filter dynamically from the connected profiler instance. The string supports regexps.

enableGCTracking()

Enables tracking of garbage collection events on the connected profiler instance. OnGCStarted/Ended/Completed need this enabled to operate.

disableGCTracking()

Disables tracking of garbage collection events on the connected profiler instance.

enableAllocationTracking()

Enables tracking of allocations on the connected profiler instance. onAllocation() as well as the aggregated information about method allocations need this to work.

disableAllocationTracking()

Disables tracking of allocations on the connected profiler instance.

enableMethodTracking()

Enables tracking of fine grained method events on the connected profiler instance. onMethodCalled() and the data about method calls need this enabled in order to work.

disableMethodTracking()

Disables tracking of fine grained method events on the connected profiler instance.

enableExceptionTracking()

Enables tracking of Exception events on the connected profiler instance.

disableExceptionTracking()

Disables tracking of Exception events on the connected profiler instance.

Queries

###threads()

Returns the current running threads in the process.

###dumpThreads()

Dumps current threads and their stack traces.

###dumpThread(threadId : uint64)

Dumps thread by id and its stack trace

###mostCalledMethods() : seq

Returns methods sorted by how many times they have been called.

###mostAllocatingMethods() : seq

Returns methods sorted by how many allocations have been done effectively in that method (eg with filtering applied).

###mostActualAllocatingMethods() : seq

Returns methods sorted by how many actual allocations have been done (eg without filtering applied).

Observables

onAllocation()

Returns an observable for when an allocation occurs.

onException()

Returns an observable for when an Exception occurs.

onGCStart()

Returns an observable for when garbage collection starts.

onGCEnd()

Returns an observable for when garbage collection ends.

onGCCompleted()

Returns an observable for when garbage collection ends, tying it back to when it started (providing times). If there was no start this observable will not be raised.

onMethodEnter()

Returns an observable for when a method is entered (affected by filtering).

onMethodLeave()

Returns an observable for when a method is left (affected by filtering).

onMethodCalled()

Returns an observable representing when a method is called. This observable is triggered on leaving a method and includes the duration of the method call.

You can’t perform that action at this time.