SiMaLaoShi / LuaProfiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lua Profiler For Unity


Purpose

Unity + Lua script is now most popular incremental update frameWork for mobile game in China , But because that not has an easy-to-use profiler cause more cpu usage to lua gc and also more memory usage . so much so that programmers don't know how to optimize their game . Then they replace lua code with C# to find the problems , but also more buildin code and less flexibility in operation activity .
so this tool is designed to support an easy-to-use profiler for unity that help finding battleneck and make your game more fast and stable.

If you want to test this project,use administrator mode to run the link.bat

Contact

If you find any bug or have any suggests join the QQ group:882425563 to contact us

Deploy and Install

This tool now supports XLuaSLuaToLua.This is a remote profiler tool so it supports WindowsAndroidIOS On-device Profiler.

  • Open LuaProfiler folder
  • Copy LuaProfilerClient folder to you game project content,if your C# Lua script is in Plugins folder,Copy LuaProfilerClient to Plugins.This Tool must make sure That code must in the same DLL which has C# lua codes.
  • Use Unity5.6 or newer unity version to create a project, copy LuaProfilerServer to the project content

Theory

It use mono.ceil's IL inject feature(also use in XLua),inject the profiler code to game code

Tutors

you must open two unity projects,one for game client ,one for editor server

Config your client

Open windows by "Window->Lua Profiler Window", toggle profiler's feature and configure the server ip address.

Open server

Also open windows by "Window->Lua Profiler Window", then click OpenService,wait for client connects

Record mode

Click Record button, when game connect to server, toggle StartRecord to start or stop record.

Record button feature
  • drag slider to modify samples
  • click '<''>' to increase or discrease frames one by one
  • click '<<''>>' to fast locate the frames control by Capture Lua GCCapture Mono GCFrame Count
  • stop record and press left or right arrow keybord to increase or discrease frames one by one

On-device Profiler

Set macro USE_LUA_PROFILER to inject profiler code in you App.If you want to use luac code or luajit bytecode ,use InjectLua.exe in folder tools To inject the lua profiler code.

InjectLua.exe "inpath" "outpath"

Use Case

Thanks

easy66
Xavier
Jay
ZhangDi
and all members in qq group LuaProfiler

About

License:Apache License 2.0


Languages

Language:C# 88.9%Language:Lua 11.0%Language:C++ 0.1%Language:Batchfile 0.0%