3 篇文章带有标签 “lua”

HTTP 基准测试工具

wrk

wrk 使用的是 HTTP/1.1

安装

需要从 GitHub 上克隆代码自己编译,编译前需要安装 git, gcc。

git clone https://github.com/wg/wrk.git
cd wrk
#使用多线程(机器的处理器核数)加速编译,
make -j $(nproc)
cp wrk /usr/local/bin/

测试

10 个线程,保持打开 100 个并发连接,持续 10 秒。

wrk -t10 -c100 -d10 http://www.baidu.com/
Running 10s test @ http://www.baidu.com/
  10 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   138.46ms  219.05ms   1.89s    92.11%
    Req/Sec   128.07     79.83   700.00     94.40%
  12776 requests in 10.02s, 128.22MB read
  Socket errors: connect 0, read 57, write 0, timeout 3
Requests/sec:   1275.30
Transfer/sec:     12.80MB

打印详细的延时分布信息 wrk -c10 -t4 --latenc

OpenResty 内执行 Lua 脚本

OpenResty 是一款基于 NGINX 和 LuaJIT 的 Web 平台。

拉取 OpenResty 镜像

  • Ubuntu
sudo docker pull openresty/openresty:xenial
  • CentOS
sudo docker pull openresty/openresty:centos

查看镜像的标签 $ sudo docker inspect openresty/openresty:centos | jq '.[].Config.Labels' { "maintainer": "Evan Wies <evan@neomantra.net>", "org.label-schema.build-date": "20210915", "org.label-schema.license": "GPLv2", "org.label-schema.name": "CentOS Base Image", "org.label-schema.schema-version": "1.0", "org.label-schema.

VLC Extension Example

开发

编写脚本 hello.lua

function descriptor()
    return {
        title = "Hello World";
        version = "1.0";
        author = "WangJunjian";
        url = 'www.wangjunjian.com';
        shortdesc = "Hello World";
        description = "Hello World!";
        capabilities = {"menu"}
    }
end

-- activate() : called when the extension is activated from within VLC
function activate()
    create_dialog()
end

-- deactivate() : called when the extension is deactivated from within VLC
function deactivate()
    close()
    vlc.deactivate()
end

-- create_dialog() : creates the dialog containing the initial widgets
function create_dialog()
    dlg = vlc.dialog(descriptor().title)
    dlg:add_label("<b>Hello World: VLC Lua scripts and extensions</b>")
end