Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ script:
- ls -l /usr/local/lib/
- ls -l /usr/lib/
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then cd ../src/; cppcheck --error-exitcode=1 .; cd ../build; fi
- |
if [ "$PERFORMANCE" = "select" ]; then
cd examples
./benchmark_select 8080 $(nproc) &
sleep 5 && ab -n 10000000 -c 100 localhost:8080/plaintext
fi
- |
if [ "$PERFORMANCE" = "threads" ]; then
cd examples
./benchmark_threads 8080 &
sleep 5 && ab -n 10000000 -c 100 localhost:8080/plaintext
fi
after_success:
- if [ "$DEBUG" = "debug" ] && [ "$COVERAGE" = "coverage" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then bash <(curl -s https://codecov.io/bash); fi
matrix:
Expand Down Expand Up @@ -193,6 +205,26 @@ matrix:
- valgrind-dbg
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7 && VALGRIND=valgrind"
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
- apache2-utils
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7 && PERFORMANCE=select"
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
- apache2-utils
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7 && PERFORMANCE=threads"
#- os: osx
# osx_image: xcode8
# env:
Expand Down
4 changes: 3 additions & 1 deletion examples/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
LDADD = $(top_builddir)/src/libhttpserver.la
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/httpserver/
METASOURCES = AUTO
noinst_PROGRAMS = hello_world service minimal_hello_world custom_error allowing_disallowing_methods handlers hello_with_get_arg setting_headers custom_access_log basic_authentication digest_authentication minimal_https minimal_file_response minimal_deferred url_registration minimal_ip_ban
noinst_PROGRAMS = hello_world service minimal_hello_world custom_error allowing_disallowing_methods handlers hello_with_get_arg setting_headers custom_access_log basic_authentication digest_authentication minimal_https minimal_file_response minimal_deferred url_registration minimal_ip_ban benchmark_select benchmark_threads

hello_world_SOURCES = hello_world.cpp
service_SOURCES = service.cpp
Expand All @@ -37,3 +37,5 @@ minimal_file_response_SOURCES = minimal_file_response.cpp
minimal_deferred_SOURCES = minimal_deferred.cpp
url_registration_SOURCES = url_registration.cpp
minimal_ip_ban_SOURCES = minimal_ip_ban.cpp
benchmark_select_SOURCES = benchmark_select.cpp
benchmark_threads_SOURCES = benchmark_threads.cpp
68 changes: 0 additions & 68 deletions examples/benchmark.cpp

This file was deleted.

40 changes: 40 additions & 0 deletions examples/benchmark_select.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <httpserver.hpp>
#include <cstdlib>
#include <memory>

#define PATH "/plaintext"
#define BODY "Hello, World!"

using namespace httpserver;

class hello_world_resource : public http_resource {
public:
hello_world_resource(const std::shared_ptr<http_response>& resp):
resp(resp)
{
}

const std::shared_ptr<http_response> render(const http_request&) {
return resp;
}

private:
std::shared_ptr<http_response> resp;
};

int main(int argc, char** argv)
{
webserver ws = create_webserver(atoi(argv[1]))
.start_method(http::http_utils::INTERNAL_SELECT)
.max_threads(atoi(argv[2]));

std::shared_ptr<http_response> hello = std::shared_ptr<http_response>(new string_response(BODY, 200));
hello->with_header("Server", "libhttpserver");

hello_world_resource hwr(hello);
ws.register_resource(PATH, &hwr, false);

ws.start(true);

return 0;
}
39 changes: 39 additions & 0 deletions examples/benchmark_threads.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <httpserver.hpp>
#include <cstdlib>
#include <memory>

#define PATH "/plaintext"
#define BODY "Hello, World!"

using namespace httpserver;

class hello_world_resource : public http_resource {
public:
hello_world_resource(const std::shared_ptr<http_response>& resp):
resp(resp)
{
}

const std::shared_ptr<http_response> render(const http_request&) {
return resp;
}

private:
std::shared_ptr<http_response> resp;
};

int main(int argc, char** argv)
{
webserver ws = create_webserver(atoi(argv[1]))
.start_method(http::http_utils::THREAD_PER_CONNECTION);

std::shared_ptr<http_response> hello = std::shared_ptr<http_response>(new string_response(BODY, 200));
hello->with_header("Server", "libhttpserver");

hello_world_resource hwr(hello);
ws.register_resource(PATH, &hwr, false);

ws.start(true);

return 0;
}