在 Ubuntu 系统中,对 ThinkPHP 进行性能测试通常涉及以下几个步骤:
安装性能测试工具:
准备测试环境:
编写测试脚本:
执行性能测试:
ab -n 1000 -c 10 http://your-app-url/
-n 1000 表示总共发送 1000 个请求。-c 10 表示同时发送 10 个请求。首先,你需要安装 Siege:
sudo apt-get install siege
然后,运行 Siege:
siege -c 10 -t 1M http://your-app-url/
-c 10 表示同时有 10 个用户访问。-t 1M 表示测试持续 1 分钟。假设你的 ThinkPHP 应用运行在 http://localhost:8080,并且你想测试 /api/test 接口:
ab -n 1000 -c 10 http://localhost:8080/api/test
siege -c 10 -t 1M http://localhost:8080/api/test
通过这些步骤,你可以对 ThinkPHP 应用进行性能测试,并根据测试结果进行优化。