问题描述
我已经克隆了uWebSockets,并写入了以下文件。
#include <App.h>
#include <iostream>
int main() {
uWS::App()
.get("/*",[](auto *res,auto *req) {
res->end("Hello world!");
})
.listen(3000,[](auto *token) {
if (token) {
std::cout << "Listening on port " << 3000 << std::endl;
}
})
.run();
std::cout << "Failed to listen on port 3000" << std::endl;
return 0;
}
内置
make -C uWebSockets/uSockets
g++ -flto -O3 -Wconversion -std=c++17 -IuWebSockets/src -IuWebSockets/uSockets/src main.cpp -o main uWebSockets/uSockets/*.o -lz -lssl -lcrypto -luv
当我进行基准测试时,这就是我得到的。
Concurrency Level: 100
Time taken for tests: 116.928 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 68000 bytes
HTML transferred: 12000 bytes
Requests per second: 8.55 [#/sec] (mean)
Time per request: 11692.844 [ms] (mean)
Time per request: 116.928 [ms] (mean,across all concurrent requests)
Transfer rate: 0.57 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 3 2.6 2 10
Processing: 8923 11690 921.2 11995 12012
Waiting: 0 1 1.3 0 10
Total: 8923 11693 921.7 11999 12012
Percentage of the requests served within a certain time (ms)
50% 11999
66% 12001
75% 12002
80% 12003
90% 12006
95% 12008
98% 12010
99% 12011
100% 12012 (longest request)
如果我将并发设置为1,则会发生
Concurrency Level: 1
Time taken for tests: 61.655 seconds
Complete requests: 5
Failed requests: 0
Total transferred: 408 bytes
HTML transferred: 72 bytes
Requests per second: 0.08 [#/sec] (mean)
Time per request: 12330.911 [ms] (mean)
Time per request: 12330.911 [ms] (mean,across all concurrent requests)
Transfer rate: 0.01 [Kbytes/sec] received
我做错了吗?我错过了什么?不是应该更快吗?
PS。我在单线程上运行它。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)