Skip to content

API Reference

Sewbacca edited this page Jun 15, 2023 · 2 revisions

Index

Item Summary
lfsampler
lfsampler.anyAvailable Checks whether an profiler is available
lfsampler.currentProfiler Retrieves current selected profiler
lfsampler.discard Discards current results. If they are not discarded, any subsequent sessions, will accumulate
lfsampler.getResults Returns current results (copy)
lfsampler.isAvailable Returns whether or not specified profiler is available
lfsampler.isRunning Return whether or not the profiler is running
lfsampler.popResults Returns results and then discards them. Use this if you want to have seperate session results.
lfsampler.setProfiler Sets profiler to use
lfsampler.start Starts the session
lfsampler.stop Stops the session
lfsampler.AccumulatedProbe
lfsampler.AccumulatedProbe.callCount
lfsampler.AccumulatedProbe.sampleCount
lfsampler.AccumulatedProbe.stacktrace A stacktrace is just a list of locations
lfsampler.AccumulatedResults Containing unique stacktraces, accumulated over all samples
lfsampler.Location Represents a stackframe location
lfsampler.Location.file
lfsampler.Location.func
lfsampler.Location.line
lfsampler.Probe A probe, containing info about samples inside a specific stacktrace
lfsampler.Probe.sampleCount
lfsampler.Probe.stacktrace A stacktrace is just a list of locations
lfsampler.ProfilerResults
lfsampler.ProfilerResults:accumulate Accumulates all stacktraces collapsed by given hash function
lfsampler.ProfilerResults.actualRate Rate in millisecond per sample
lfsampler.ProfilerResults.duration Accumulated duration
lfsampler.ProfilerResults:new
lfsampler.ProfilerResults.probes
lfsampler.ProfilerResults:squash Same as accumulate, but keeps order.
lfsampler.ProfilerResults.totalSamples Total sample count
lfsampler.ProfilerType ```lua
lfsampler.SquashedOrderedResults Same as lfsampler.AccumulatedResults, but keeps the order, so the stacktraces may not be unique
lfsampler.Stacktrace A stacktrace is just a list of locations
lfsampler.formatters A collection of functions to interpret lfsampler.ProfilerResults
lfsampler.formatters.annotateSource Returns completly annotated source code foreach module
lfsampler.formatters.flamegraph Formats results according to FlameGraph
lfsampler.formatters.formatReport Formats given results into an easly printable report.
lfsampler.formatters.granularityFunc Hash function for stacktrace by function name
lfsampler.formatters.granularityLine Hash function for stacktrace by file and function name and line
lfsampler.formatters.sortBySampleCount Comparates two { sampleCount: integer } by >

lfsampler

lfsampler.anyAvailable()

Checks whether an profiler is available

Returns

  • boolean

lfsampler.currentProfiler()

Retrieves current selected profiler

Returns

  • "debug"|"dummy"|"jit"

lfsampler.discard()

Discards current results. If they are not discarded, any subsequent sessions, will accumulate

lfsampler.getResults()

Returns current results (copy)

Returns

lfsampler.isAvailable(profiler_type)

Returns whether or not specified profiler is available

Args:

  • profiler_type - any

Returns

  • boolean

lfsampler.isRunning()

Return whether or not the profiler is running

Returns

  • boolean

lfsampler.popResults()

Returns results and then discards them. Use this if you want to have seperate session results.

Returns

lfsampler.setProfiler(profiler_type, n)

Sets profiler to use

Args:

  • profiler_type - "debug"|"dummy"|"jit"
    • jit uses jit.profile, debug uses the debug api, and dummy does absolutly nothing
  • n - integer
    • debug: The instruction rate at which samples are collected, jit: Sample rate in milliseconds. Is OS-Dependant

lfsampler.start()

Starts the session

lfsampler.stop()

Stops the session

Back to index

lfsampler.AccumulatedProbe

lfsampler.AccumulatedProbe.callCount

  • type: integer

lfsampler.AccumulatedProbe.sampleCount

  • type: integer

lfsampler.AccumulatedProbe.stacktrace

A stacktrace is just a list of locations

Back to index

lfsampler.AccumulatedResults

Back to index

lfsampler.Location

lfsampler.Location.file

  • type: string

lfsampler.Location.func

  • type: string

lfsampler.Location.line

  • type: number

Back to index

lfsampler.Probe

lfsampler.Probe.sampleCount

  • type: integer

lfsampler.Probe.stacktrace

A stacktrace is just a list of locations

Back to index

lfsampler.ProfilerResults

lfsampler.ProfilerResults:accumulate(hash)

Accumulates all stacktraces collapsed by given hash function

Args:

Returns

lfsampler.ProfilerResults.actualRate

Rate in millisecond per sample

  • type: number

lfsampler.ProfilerResults.duration

Accumulated duration

  • type: integer

lfsampler.ProfilerResults:new()

Returns

lfsampler.ProfilerResults.probes

lfsampler.ProfilerResults:squash(hash)

Same as accumulate, but keeps order.

Args:

Returns

lfsampler.ProfilerResults.totalSamples

Total sample count

  • type: integer

Back to index

lfsampler.ProfilerType

  • Alias: "debug"|"dummy"|"jit"

Back to index

lfsampler.SquashedOrderedResults

Back to index

lfsampler.Stacktrace

Back to index

lfsampler.formatters

lfsampler.formatters.annotateSource(results, searchDirs)

Returns completly annotated source code foreach module

Args:

  • results - lfsampler.ProfilerResults
  • searchDirs - string?
    • Semicolon seperated list of extra search paths (beside package.path)

Returns

  • table<string, string>
    • { [path]: annotations }

lfsampler.formatters.flamegraph(results, type, granularityFormatter)

Formats results according to FlameGraph Format: <file>(:<line>)?-<func>;... <samples>\n...

Args:

Returns

  • string

lfsampler.formatters.formatReport(results)

Formats given results into an easly printable report.

Args:

Returns

  • string

lfsampler.formatters.granularityFunc(stacktrace)

Hash function for stacktrace by function name

Args:

Returns

  • string

lfsampler.formatters.granularityLine(stacktrace)

Hash function for stacktrace by file and function name and line

Args:

Returns

  • string

lfsampler.formatters.sortBySampleCount(a, b)

Comparates two { sampleCount: integer } by >

Args:

  • a - any
  • b - any

Returns

  • boolean

Back to index

Clone this wiki locally