Git Product home page Git Product logo

lua-profiler's Introduction

lua-profiler

A simple Lua profiler. Requires Lua 5.3.

  • Supports recursive calls.
  • Supports tail calls.
  • Minimalistic.
  • Pretty report output format.

Obsolete

This library is no longer maintained. See this repository for a reimplementation in Rust.

Installation

Compile the hook, and put profile_hook.so in Lua's package.cpath (e.g. /usr/lib/lua/5.3).

$ gcc -O3 -Wall -Wextra -pedantic -fPIC -shared c/profile_hook.c -o profile_hook.so

Put lua/profile.lua in Lua's package.path (e.g. /usr/share/lua/5.3).

Usage

require("profile") returns a function with the following parameters:

  1. f (function): a function to profile.
  2. path (string; default ./profiler-report.txt): a path to put the report to.
  3. obscureAnonymous (boolean; default false): if true, the hook will use the address as a name of anonymous functions, otherwise, <anon> is used.
local function factorial(n, acc)
  acc = acc or 1

  if n <= 1 then
    return acc
  else
    return factorial(n - 1, n * acc)
  end
end

require("profile")(function()
  return factorial(10)
end)

lua-profiler's People

Contributors

fingercomp avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lua-profiler's Issues

Lua 5.2 support

I don't want to bother with Lua 5.1, but Lua 5.2 is nice to have. I think I just need to get rid of lua_rotate calls.

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.