Coder Social home page Coder Social logo

lmprof's Introduction

lmprof
==============

A Memory Profiler for the Lua language

* Author: Pablo Musa
* Creation Date: may 21 2014
* Last Modification: aug 18 2014
* See Copyright Notice in LICENSE

lmprof is a library for the Lua language (version 5.2 or higher) that collects
information about the memory usage of a program throughout its execution and
then analyze the collected data to generate reports.
The memory use of the program using our library can be seen in a flat
or in call-graph profile.

Read INSTALL to see the library dependencies.

Use the following command to load the library into a local variable:
local lmprof = require"lmprof"

*
* lmprof monitor API
*
-- starts the memory monitor and write to a file in Lua table format the number
-- of calls, the memory allocated only by the function and the memory allocated
-- by the function and its children for all the pairs (function, parent) that
-- allocated memory.
-- can be used without stop to monitor the full execution.
-- if start is used in a "inner function level" (ex: inside a function call)
-- there must be a stop in the same function level.
-- if no filename is passed the output is written to "lmprof_default_output.lua"
lmprof.start([output_file_name])

-- stops the memory monitor and output to a file in Lua table format.
-- passing a filename in this call overwrites the filename passed to start.
-- as said before, stop must be used in the same function level as start.
lmprof.stop([output_file_name])

*
* lmprof reduce
*
To see the report of the monitored program there are a few options.

$> lua text.lua <flat | call | all> <lmprof_output_file_location> [size]

flat profile: A summary of function allocations ordered by the amount of data
allocated by each function alone.

call-graph profile: A detailed report by function with parents and children
information.

all: both of the above profiles

The optional size parameter limits the number of functions of the output.

*
* Some Considerations
*
Calling the start function twice raises an error.

The library monitors only the interval between start and stop. Memory operations
done before the start call, or after the stop call are not counted.

If you call start in the main script execution, you do not need to call stop.

For multiple-states, one should explicity indicate different files, otherwise
the output of the last state will overwritte the others.

lmprof's People

Contributors

pmusa avatar

Watchers

thinkthen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.