Giter Club home page Giter Club logo

lua-resty-gperftools's Introduction

lua-resty-gperftools

Lua API for ngx_google_perftools_profiler_module

Before use these tools, you must compile nginx/openresty with ngx_google_perftools_profiler_module

Installation

Please use opm, such as :

opm get chronolaw/lua-resty-gperftools

Usage

Some simple examples:

    location /gperftools {
        content_by_lua_block {
            local gperftools = require "resty.gperftools"

            local profiler = ngx.var.arg_profiler
            local action = ngx.var.arg_action
            local name = ngx.var.arg_name

            gperftools[profiler][action](name)

            -- or profiler in 10 seconds
            -- gperftools[profiler][action](name, 10)

            ngx.say("OK")
        }
    }

Then you can start/stop gperftools with curl like below:

    curl 'http://127.0.0.1/gperftools?profiler=cpu&action=start&name=/tmp/ngx_prof'
    ...     # ab/http_load/wrk and so on
    curl 'http://127.0.0.1/gperftools?profiler=cpu&action=stop'

API

ok, err = gperftools.cpu.start(name, during)

Start cpu profiler, infomations stores in name.

If during is given, the profiler will STOP after during seconds.

Notice: It will NOT add pid suffix for the name.

gperftools.cpu.stop()

Stop cpu profiler.

gperftools.heap.start(name, n, during)

Start heap profiler, infomations stores in name, dump for every n seconds.

If during is given, the profiler will STOP after during seconds.

Notice: It will NOT add pid suffix for the name.

gperftools.heap.dump(s)

Dump heap profiler infomations, s for the reason.

gperftools.heap.stop()

Stop heap profiler.

lua-resty-gperftools's People

Contributors

chronolaw avatar

Watchers

 avatar  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.