Browse Source

add new freamwork: cinatra (#5379)

* Create README.md

* Create benchmark_config.json

* Update README.md

* Create cinatra.dockerfile

* Create CMakeLists.txt

* Create main.cpp

* Update cinatra.dockerfile

* Update CMakeLists.txt

* Update README.md

* Update README.md

* Update cinatra.dockerfile
qicosmos 5 years ago
parent
commit
1f27afc200

+ 13 - 0
frameworks/C++/cinatra/README.md

@@ -0,0 +1,13 @@
+# cinatra Benchmarking Test
+
+cinatra is a high-performance, easy-to-use http framework developed in Modern C++ (C++17) with the goal of making it easy and quick to develop web applications using the C++ programming language, located at https://github.com/qicosmos/cinatra
+
+## Testing Source Code
+
+* [PLAINTEXT](cinatra_benchmark/main.cpp)
+
+## Test URLs
+
+### PLAINTEXT
+
+http://localhost:8089/plaintext

+ 23 - 0
frameworks/C++/cinatra/benchmark_config.json

@@ -0,0 +1,23 @@
+{
+  "framework": "cinatra",
+  "tests": [{
+    "default": {
+      "plaintext_url": "/plaintext",
+      "port": 8090,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "None",
+      "framework": "cinatra",
+      "language": "C++",
+      "flavor": "None",
+      "orm": "None",
+      "platform": "None",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "cinatra",
+      "notes": "",
+      "versus": "cinatra"
+    }
+  }]
+}

+ 29 - 0
frameworks/C++/cinatra/cinatra.dockerfile

@@ -0,0 +1,29 @@
+FROM ubuntu:18.04
+
+RUN apt-get update -yqq && \
+	apt-get install -yqq cmake git uuid-dev gcc g++ autoconf
+
+ENV IASIO=/asio/asio
+ENV CINATRA_HOME=/cinatra
+ENV CINATRA=/cinatra/example
+
+RUN git clone https://github.com/chriskohlhoff/asio.git
+RUN git checkout 8087252a0c3c2f0baad96ddbd6554db17a846376
+
+WORKDIR $IASIO
+
+RUN ./autogen.sh && ./configure
+RUN make -j && make install
+
+WORKDIR /
+
+RUN git clone https://github.com/qicosmos/cinatra.git
+RUN git checkout 3f2d75fa8d249ccecce56530a67205793caeb18a
+
+WORKDIR $CINATRA
+
+RUN mkdir build && cd build && cmake .. && make
+
+EXPOSE 8090
+
+CMD ./build/cinatra_example

+ 65 - 0
frameworks/C++/cinatra/cinatra_benchmark/CMakeLists.txt

@@ -0,0 +1,65 @@
+cmake_minimum_required(VERSION 3.0)
+set(project_name cinatra_example)
+project(${project_name})
+include_directories($ENV{CINATRA_HOME})
+if (MSVC)
+	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest")
+else ()
+	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -O3 -pthread -msse4.2 -std=c++17")
+endif ()
+
+SET(ENABLE_GZIP OFF)
+SET(ENABLE_SSL OFF)
+SET(ENABLE_CLIENT_SSL OFF)
+SET(ENABLE_ASIO_STANDALONE ON)
+
+if (ENABLE_SSL)
+	add_definitions(-DCINATRA_ENABLE_SSL)
+	message(STATUS "Use SSL")
+endif()
+
+if(ENABLE_GZIP)
+	add_definitions(-DCINATRA_ENABLE_GZIP)
+endif()
+
+if(ENABLE_CLIENT_SSL)
+	add_definitions(-DCINATRA_ENABLE_CLIENT_SSL)
+endif()
+
+if(ENABLE_ASIO_STANDALONE)
+	add_definitions(-DASIO_STANDALONE)
+else()
+	find_package(Boost 1.60 REQUIRED COMPONENTS system)
+endif()
+
+if (ENABLE_SSL)
+find_package(OpenSSL REQUIRED)
+endif()
+if (ENABLE_CLIENT_SSL)
+	find_package(OpenSSL REQUIRED)
+endif()
+
+if (ENABLE_GZIP)
+	find_package(ZLIB REQUIRED)
+endif()
+
+set(CINATRA_EXAMPLE
+	main.cpp
+	)
+
+add_executable(${project_name} ${CINATRA_EXAMPLE})
+include_directories(${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})
+
+target_link_libraries(${project_name} ${Boost_LIBRARIES} uuid -lstdc++fs)
+if (ENABLE_SSL)
+	target_link_libraries(${project_name} ${OPENSSL_LIBRARIES} pthread -ldl)
+endif()
+
+if (ENABLE_CLIENT_SSL)
+	target_link_libraries(${project_name} ${OPENSSL_LIBRARIES} pthread -ldl)
+endif()
+
+if (ENABLE_GZIP)
+	target_link_libraries(${project_name} ${ZLIB_LIBRARIES})
+endif()
+install(TARGETS ${project_name} DESTINATION include)

+ 20 - 0
frameworks/C++/cinatra/cinatra_benchmark/main.cpp

@@ -0,0 +1,20 @@
+#include <iostream>
+#include <include/cinatra.hpp>
+
+using namespace cinatra;
+
+int main() {
+	http_server server(std::thread::hardware_concurrency());
+	bool r = server.listen("0.0.0.0", "8090");
+	if (!r) {
+		std::cout << "listen failed\n";
+		return -1;
+	}
+
+	server.set_http_handler<GET>("/plaintext", [](request& req, response& res) {
+		res.set_status_and_content(status_type::ok, "Hello, World!", res_content_type::string);
+	});
+
+	server.run();
+	return 0;
+}