File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,46 +3,7 @@ lua-var-nginx-module
33
44Fetchs Nginx variable by Luajit with FFI way which is fast and cheap.
55
6- ``` lua
7- local function test1 ()
8- local start_time = ngx .now ()
9-
10- local var = ngx .var
11- local uri
12- for i = 1 , 10000 * 1000 do
13- uri = var .uri
14- if not uri then
15- uri = uri .. " xxx"
16- end
17- end
18-
19- ngx .update_time ()
20- ngx .say (" ngx.var directly, used time: " , ngx .now () - start_time )
21- end
22-
23- local function test2 ()
24- local start_time = ngx .now ()
25-
26- local ngxvar = require (" resty.ngxvar" ).fetch
27- local req = ngxvar (" _request" )
28- local uri
29-
30- for i = 1 , 10000 * 1000 do
31- uri = ngxvar (" uri" , req )
32- if not uri then
33- uri = uri .. " xxx"
34- end
35- end
36-
37- ngx .update_time ()
38- ngx .say (" ngxvar patch, used time: " , ngx .now () - start_time )
39- end
40-
41- test1 () -- ngx.var directly, used time: 0.49900007247925
42- test2 () -- fetch with ngxvar, used time: 0.08299994468689
43- ```
44-
45- Compares to ` ngx.var ` , performance has increased by more than five times. ^_ ^
6+ Compares to ` ngx.var.* ` , performance has increased by more than five times. ^_ ^
467
478
489Table of Contents
You can’t perform that action at this time.
0 commit comments