Add benchmark tool
This commit is contained in:
parent
b4989130da
commit
c75d071615
3
.gitignore
vendored
3
.gitignore
vendored
@ -21,6 +21,8 @@ test/test.xcodeproj/*/xcuser*
|
|||||||
test/*.o
|
test/*.o
|
||||||
test/*.pem
|
test/*.pem
|
||||||
test/*.srl
|
test/*.srl
|
||||||
|
benchmark/server
|
||||||
|
benchmark/server-crow
|
||||||
|
|
||||||
*.swp
|
*.swp
|
||||||
|
|
||||||
@ -34,6 +36,7 @@ Release
|
|||||||
*.db
|
*.db
|
||||||
ipch
|
ipch
|
||||||
*.dSYM
|
*.dSYM
|
||||||
|
*.pyc
|
||||||
.*
|
.*
|
||||||
!/.gitattributes
|
!/.gitattributes
|
||||||
!/.travis.yml
|
!/.travis.yml
|
||||||
|
31
benchmark/Makefile
Normal file
31
benchmark/Makefile
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
CXXFLAGS = -std=c++14 -O2 -I..
|
||||||
|
|
||||||
|
THEAD_POOL_COUNT = 16
|
||||||
|
BENCH_FLAGS = -c 8 -d 5s
|
||||||
|
|
||||||
|
# cpp-httplib
|
||||||
|
bench: server
|
||||||
|
@./server & export PID=$$!; bombardier $(BENCH_FLAGS) localhost:8080; kill $${PID}
|
||||||
|
|
||||||
|
server : cpp-httplib/main.cpp ../httplib.h
|
||||||
|
g++ -o $@ $(CXXFLAGS) -DCPPHTTPLIB_THREAD_POOL_COUNT=$(THEAD_POOL_COUNT) cpp-httplib/main.cpp
|
||||||
|
|
||||||
|
run : server
|
||||||
|
@./server
|
||||||
|
|
||||||
|
# crow
|
||||||
|
server-crow : crow/main.cpp
|
||||||
|
g++ -o $@ $(CXXFLAGS) crow/main.cpp
|
||||||
|
|
||||||
|
bench-crow: server-crow
|
||||||
|
@./server-crow & export PID=$$!; bombardier $(BENCH_FLAGS) localhost:8080; kill $${PID}
|
||||||
|
|
||||||
|
# flask
|
||||||
|
bench-flask:
|
||||||
|
@FLASK_APP=flask/main.py flask run --port=8080 & export PID=$$!; bombardier $(BENCH_FLAGS) localhost:8080; kill $${PID}
|
||||||
|
|
||||||
|
# misc
|
||||||
|
bench-all: bench bench-crow bench-flask
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf server*
|
12
benchmark/cpp-httplib/main.cpp
Normal file
12
benchmark/cpp-httplib/main.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "httplib.h"
|
||||||
|
using namespace httplib;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
Server svr;
|
||||||
|
|
||||||
|
svr.Get("/", [](const Request &, Response &res) {
|
||||||
|
res.set_content("Hello World!", "text/plain");
|
||||||
|
});
|
||||||
|
|
||||||
|
svr.listen("0.0.0.0", 8080);
|
||||||
|
}
|
14316
benchmark/crow/crow_all.h
Normal file
14316
benchmark/crow/crow_all.h
Normal file
File diff suppressed because it is too large
Load Diff
17
benchmark/crow/main.cpp
Normal file
17
benchmark/crow/main.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include "crow_all.h"
|
||||||
|
|
||||||
|
class CustomLogger : public crow::ILogHandler {
|
||||||
|
public:
|
||||||
|
void log(std::string, crow::LogLevel) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
CustomLogger logger;
|
||||||
|
crow::logger::setHandler(&logger);
|
||||||
|
|
||||||
|
crow::SimpleApp app;
|
||||||
|
|
||||||
|
CROW_ROUTE(app, "/")([]() { return "Hello world!"; });
|
||||||
|
|
||||||
|
app.port(8080).multithreaded().run();
|
||||||
|
}
|
9
benchmark/flask/main.py
Normal file
9
benchmark/flask/main.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from flask import Flask
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
import logging
|
||||||
|
logging.getLogger('werkzeug').disabled = True
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def hello_world():
|
||||||
|
return 'Hello, World!'
|
Loading…
x
Reference in New Issue
Block a user