Module tch.profiling

A simple profiling module.

Every time start() is called it will record a timestamp on a stack. Every time stop() is called it will calculate the elapsed time with the timestamp currently on the top of the stack. This info is used to build a call tree with timings. Note that this means you have to use the functions in a balanced way.

This is an internal development module and normally not installed on target.

Usage:

    local profiling = require("tch.profiling")
    local function some_time_consuming_function()
      profiling.start("some_time_consuming_function")
      calculations here
      profiling.stop("some_time_consuming_function")
    end
    local function foo()
      profiling.start("foo")
      some_time_consuming_function()
      some_other_time_consuming_function()
      profiling.stop("foo")
      profiling.dump("/tmp/profile.log")
    end
    

Functions

dump(filename, append) Write the collected profiling data to the given file.
start(name) Record a starting timestamp with the given name.
stop(name) Take a new timestamp, calculate the elapsed time since the timestamp at the top of the stack and record it with the given name.


Functions

dump(filename, append)
Write the collected profiling data to the given file.

Parameters:

  • filename string The full path to the file to write the data to.
  • append bool Whether to append to the given filename or overwrite it.

See also:

start(name)
Record a starting timestamp with the given name. You can nest calls to this function. The recorded timestamps are organized in a stack.

Parameters:

  • name string A description for the timestamp.

See also:

stop(name)
Take a new timestamp, calculate the elapsed time since the timestamp at the top of the stack and record it with the given name.

Parameters:

  • name string A description for the elapsed time. It doesn't have to be the same name as in the start() call but it might help help to interpret the results.

See also:

generated by LDoc 1.4.5 Last updated 2017-05-04 22:24:31