hello, 这里我打算用埋点的测试方式,将请求在我的access阶段逻辑中各个阶段的耗时打印出来,看主要耗时在哪块,
但ngx.now()只能是毫秒级别的,所以想用ffi调用gettimeofday来测出微秒级别的,我的ffi是这么写的,但是编译不通过:
ocal ffi=require 'ffi'
ffi.cdef[[
int gettimeofday(struct timeval*tv,struct timezone*tv);
typedef struct timeval type_tv;
typedef struct timezone type_tz;
]]
--local test=ffi.C.printf("hello,%s\n","world")
--local type_tv=ffi.typeof("struct timeval")
--local type_tz=ffi.typeof("struct timezone")
local tv=ffi.new("type_tv[?]",1)
local tz=ffi.new("type_tz[?]",1)
local res=ffi.C.gettimeofday(tv,tz)
但一直出错
2017/02/28 12:07:27 [error] 5886#0: *2605537 lua entry thread aborted: runtime error: /home/ke/test/flow_deg/t/ffi.lua:11: size of C type is unknown or too large
stack traceback:
coroutine 0:
[C]: in function 'new'
/home/ke/test/flow_deg/t/ffi.lua:11: in function </home/ke/test/flow_deg/t/ffi.lua:1>, client: 127.0.0.1, server: , request: "GET /test_ffi HTTP/1.1", host: "localhost"
在 2017年2月23日星期四 UTC+8下午5:46:05,wwaz wwaz写道:
在nginx里面在access阶段跑lua代码,
用ab测试的,ab -50000 -c100,一共测试了10次,取平均值。发现在加了access前后,请求耗时平均值有1-2ms的差距
现在有两个问题请教大家:
1 一般都是如何压测nginx的呀?用wrk?or ab么?
2 由于自己写的lua代码,如何查看瓶颈点在哪里呢?听说luajit有相应的工具,(用火焰图么,感觉有点重型武器了),