Skip to content

Commit c75d071

Browse files
committed
Add benchmark tool
1 parent b498913 commit c75d071

File tree

6 files changed

+14388
-0
lines changed

6 files changed

+14388
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ test/test.xcodeproj/*/xcuser*
2121
test/*.o
2222
test/*.pem
2323
test/*.srl
24+
benchmark/server
25+
benchmark/server-crow
2426

2527
*.swp
2628

@@ -34,6 +36,7 @@ Release
3436
*.db
3537
ipch
3638
*.dSYM
39+
*.pyc
3740
.*
3841
!/.gitattributes
3942
!/.travis.yml

benchmark/Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
CXXFLAGS = -std=c++14 -O2 -I..
2+
3+
THEAD_POOL_COUNT = 16
4+
BENCH_FLAGS = -c 8 -d 5s
5+
6+
# cpp-httplib
7+
bench: server
8+
@./server & export PID=$$!; bombardier $(BENCH_FLAGS) localhost:8080; kill $${PID}
9+
10+
server : cpp-httplib/main.cpp ../httplib.h
11+
g++ -o $@ $(CXXFLAGS) -DCPPHTTPLIB_THREAD_POOL_COUNT=$(THEAD_POOL_COUNT) cpp-httplib/main.cpp
12+
13+
run : server
14+
@./server
15+
16+
# crow
17+
server-crow : crow/main.cpp
18+
g++ -o $@ $(CXXFLAGS) crow/main.cpp
19+
20+
bench-crow: server-crow
21+
@./server-crow & export PID=$$!; bombardier $(BENCH_FLAGS) localhost:8080; kill $${PID}
22+
23+
# flask
24+
bench-flask:
25+
@FLASK_APP=flask/main.py flask run --port=8080 & export PID=$$!; bombardier $(BENCH_FLAGS) localhost:8080; kill $${PID}
26+
27+
# misc
28+
bench-all: bench bench-crow bench-flask
29+
30+
clean:
31+
rm -rf server*

benchmark/cpp-httplib/main.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include "httplib.h"
2+
using namespace httplib;
3+
4+
int main() {
5+
Server svr;
6+
7+
svr.Get("/", [](const Request &, Response &res) {
8+
res.set_content("Hello World!", "text/plain");
9+
});
10+
11+
svr.listen("0.0.0.0", 8080);
12+
}

0 commit comments

Comments
 (0)