Lua performance

208 views
Skip to first unread message

DevX

unread,
Jul 16, 2019, 11:02:17 AM7/16/19
to openresty-en
Hi,

I want to check the processing time of my nginx Lua code. But Lua doesn't support milliseconds. Is there a way to check the response time.

Thanks

Thibault Charbonnier

unread,
Jul 16, 2019, 12:49:56 PM7/16/19
to openre...@googlegroups.com
Nginx certainly supports milliseconds precision, and so does OpenResty.

See:

https://github.com/openresty/lua-nginx-module#ngxnow
https://github.com/openresty/lua-nginx-module#ngxupdate_time

Don't forget to call ngx.update_time() if your Lua code is not yielding
in between two ngx.now() calls.

Secondly, many Nginx variables expose various underlying timing metrics:

http://nginx.org/en/docs/varindex.html

You can read them in Lua via the ngx.var.VARIABLE API
(https://github.com/openresty/lua-nginx-module#ngxvarvariable).

Finally, there also exist many systemtap scripts developed by OpenResty
to help you measure the performance of your Lua code in other meaningful
manners:

https://github.com/openresty/stapxx

Note that as of today, some of these scripts may not work with the
latest OpenResty releases (contributions welcome).

Best,
Thibault

DevX

unread,
Jul 16, 2019, 1:34:29 PM7/16/19
to openresty-en
Thanks. I will check this out
Reply all
Reply to author
Forward
0 new messages