GithubHelp home page GithubHelp logo

hwgy2008 / luaprofiler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cdsama/luaprofiler

0.0 1.0 0.0 194 KB

Lua function call cost time profiler in c++.

License: MIT License

CMake 2.18% C++ 66.61% C 0.08% Lua 5.85% Python 25.28%

luaprofiler's Introduction

LuaProfiler

Lua function call duration profiler in c++.

Target version : lua 5.3

Build

prerequisite

  • compiler support c++17
  • cmake
  • vcpkg
    • fmtlib
    • rapidjson
    • lua

Add this below to settings in vscode to link deps library as static:

"cmake.configureArgs": [
        "-DVCPKG_TARGET_TRIPLET=x64-windows-static"
    ],

click Configure button or use cmake command line tool:

mkdir build
cd build
cmake .. -G "Visual Studio 15 2017 Win64" -DVCPKG_TARGET_TRIPLET=x64-windows-static

build

In vscode with cmake extension just press F7.

or

mkdir build
cmake --build ./build --config MinSizeRel --target libLuaProfiler

Integrate

  1. Link libLuaProfiler to your project.
  2. Include or copy content lua_profiler.h.
  3. Openlib with code at startup : luaopen_profiler(L);.
  4. require and use function in lua.
local luaprofiler = require("luaprofiler")

--[[
    start profile by set hook
    should call it best outside (before function call)
    what you want to profile
]]--
luaprofiler.start() 

--[[
     stop profile with remove hook
     should call it best outside (after function return)
     what you want to profile
]]--
luaprofiler.stop()

--[[
    clear all data
    should call it after report
]]--
luaprofiler.clear() 

--[[ 
    **deprecated**
    report profiling result in string
    should print or log or save it to file
]]--
-- luaprofiler.report_tree()
-- luaprofiler.report_list()

--[[ 
    report profiling result to file
    it will save it at the current working directory
    the first part of file name is timestamp
]]--
luaprofiler.report_to_file("json")
-- *.lua_profile_json.txt
luaprofiler.report_to_file("list")
-- *.lua_profile_list.txt
luaprofiler.report_to_file("tree")
-- *.lua_profile_tree.txt

Json viewer

Create standalone gui executable

pyinstaller json_viewer_main.py -w -F 

Usage

Load json file

just drag *.lua_profile_json.txt to main window.

Tips: Installing everything on windows helps to find files instantly.

Expand stack

  1. click on the arrow to expand/fold stack
  2. double click to expand the first child recursively
  3. double click to fold

test_result

Function time list

  1. click Function Time Top to change tab
  2. click header to sort column to descending order

test_result

luaprofiler's People

Contributors

cdsama avatar

Watchers

 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.