Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
70760d0
Add baseline11
LazyPanda07 May 8, 2026
ff349ce
Fix Dockerfile
LazyPanda07 May 8, 2026
8f619f2
Fixes
LazyPanda07 May 8, 2026
146eb4b
Add json test profile
LazyPanda07 May 8, 2026
8c3c0b6
Refactor
LazyPanda07 May 8, 2026
31cc08d
Add pipelined, limited-conn, upload, static test profiles
LazyPanda07 May 8, 2026
f483806
Fixes
LazyPanda07 May 8, 2026
87cf255
Add echo-ws test profile
LazyPanda07 May 8, 2026
f07f9bf
Add web-framework-python
LazyPanda07 May 9, 2026
7f1344b
Change meta.json
LazyPanda07 May 9, 2026
c61380b
Fixes
LazyPanda07 May 9, 2026
4879a16
Fix
LazyPanda07 May 9, 2026
bc029fd
Refactor
LazyPanda07 May 9, 2026
5228681
Add CMAKE_BUILD_TYPE add --prefix at install
LazyPanda07 May 9, 2026
148ef31
Fixes
LazyPanda07 May 9, 2026
d2b7b57
Fix
LazyPanda07 May 9, 2026
c6d7046
Fixes
LazyPanda07 May 9, 2026
6affb3b
Fix
LazyPanda07 May 9, 2026
004d55a
Refactor
LazyPanda07 May 9, 2026
393c03c
Fix Upload, add WITH_STACKTRACE
LazyPanda07 May 9, 2026
50ad621
Refactor
LazyPanda07 May 9, 2026
af6ccfb
Finish web-framework-python
LazyPanda07 May 9, 2026
b6454a3
Add web-framework-csharp
LazyPanda07 May 10, 2026
bfb9684
Add copying config.json, web.json
LazyPanda07 May 10, 2026
627288f
Update WebFramework to v3.4.1
LazyPanda07 May 10, 2026
923be9b
Fix
LazyPanda07 May 10, 2026
7fa709d
Fix LD_LIBRARY_PATH
LazyPanda07 May 10, 2026
1dc6b94
Remove Content-Type
LazyPanda07 May 10, 2026
3835357
Add web-framework-cc
LazyPanda07 May 10, 2026
2bf8597
Fix
LazyPanda07 May 10, 2026
8b86248
Add fflush
LazyPanda07 May 10, 2026
9bd544f
Refactor
LazyPanda07 May 10, 2026
372bd8f
Refactor
LazyPanda07 May 10, 2026
de783d9
Fix
LazyPanda07 May 10, 2026
dad7df0
Update versions
LazyPanda07 May 11, 2026
c64a4e2
Refactor
LazyPanda07 May 11, 2026
e471ca0
Update size
LazyPanda07 May 11, 2026
b87c894
Merge branch 'main' into add-web-framework
LazyPanda07 May 11, 2026
48004b5
Fix maintainers
LazyPanda07 May 11, 2026
47c5a1c
Merge branch 'main' into add-web-framework
LazyPanda07 May 11, 2026
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
20 changes: 20 additions & 0 deletions frameworks/web-framework-cc/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ubuntu:26.04 AS build

RUN apt update
RUN apt install -y uuid-dev cmake gcc g++ git unzip zip wget ninja-build

COPY web_framework_benchmark/ /app

WORKDIR /app

RUN mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=bin -DCMAKE_CXX_FLAGS="-march=native" -DCMAKE_C_FLAGS="-march=native" -G "Ninja" .. && cmake --build . -j && cmake --install .

FROM ubuntu:26.04

ENV LD_LIBRARY_PATH=/app

COPY --from=build /app/build/bin /app

WORKDIR /app

CMD ["./server"]
11 changes: 11 additions & 0 deletions frameworks/web-framework-cc/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"display_name": "WebFramework C",
"language": "C",
"engine": "WebFramework",
"type": "production",
"description": "Web framework in C++ with different language APIs(Python, C, C++, C#)",
"repo": "https://github.com/LazyPanda07/WebFramework",
"enabled": true,
"tests": [ "baseline", "limited-conn", "pipelined", "json", "upload", "static", "echo-ws" ],
"maintainers": [ "LazyPanda07" ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Binaries
out/
build/
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 4.0.0)

set(CMAKE_CXX_STANDARD 23)

set(AS_DEPENDENCY ON)
set(WITH_PYTHON_EXECUTORS OFF)
set(WITH_DOTNET_EXECUTORS OFF)
set(BUILD_CXX_API OFF)
set(BUILD_PYTHON_API OFF)
set(BUILD_CSHARP_API OFF)

set(WEB_FRAMEWORK_VERSION 3.4.2)

project(web_framework_benchmark)

include(FetchContent)

FetchContent_Declare(
WebFramework
GIT_REPOSITORY https://github.com/LazyPanda07/WebFramework.git
GIT_TAG v${WEB_FRAMEWORK_VERSION}
)

FetchContent_MakeAvailable(WebFramework)

add_subdirectory(server)
add_subdirectory(executors)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 4.0.0)

project(executors)

add_library(
${PROJECT_NAME} SHARED
src/baseline11.c
src/json_executor.c
src/pipeline.c
src/upload.c
src/ws.c
)

target_link_libraries(
${PROJECT_NAME} PRIVATE
CC_API
)

install(TARGETS ${PROJECT_NAME} DESTINATION .)
install(FILES web.json DESTINATION .)
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include <executors/executor.h>

static void parse_values(http_request_t request, int* a, int* b);

DEFINE_DEFAULT_EXECUTOR(baseline11_t, STATELESS_EXECUTOR)

DEFINE_EXECUTOR_METHOD(baseline11_t, GET_METHOD, request, response)
{
int a;
int b;

parse_values(request, &a, &b);

char buffer[32];

memset(buffer, 0, sizeof(buffer));
snprintf(buffer, sizeof(buffer), "%d", a + b);

wf_set_body(response, buffer, sizeof(buffer));
}

DEFINE_EXECUTOR_METHOD(baseline11_t, POST_METHOD, request, response)
{
int a;
int b;
int c;
bool chunked = false;
http_header_t* headers = NULL;
size_t size;

parse_values(request, &a, &b);

wf_get_http_headers(request, &headers, &size);

for (size_t i = 0; i < size; i++)
{
if (!strcmp(headers[i].key, "Transfer-Encoding"))
{
chunked = true;

break;
}
}

if (chunked)
{
http_chunk_t* chunks;
size_t size;

wf_get_chunks(request, &chunks, &size);

c = atoi(chunks[0].data);

free(chunks);
}
else
{
const char* body;
size_t size;

wf_get_http_body(request, &body, &size);

c = atoi(body);
}

char buffer[32];

memset(buffer, 0, sizeof(buffer));
snprintf(buffer, sizeof(buffer), "%d", a + b + c);

free(headers);

wf_set_body(response, buffer, sizeof(buffer));
}

void parse_values(http_request_t request, int* a, int* b)
{
query_parameter_t* query_parameters = NULL;
size_t size;

wf_get_query_parameters(request, &query_parameters, &size);

for (size_t i = 0; i < size; i++)
{
if (!strcmp(query_parameters[i].key, "a"))
{
*a = atoi(query_parameters[i].value);
}
else if (!strcmp(query_parameters[i].key, "b"))
{
*b = atoi(query_parameters[i].value);
}
}
}

DEFINE_INITIALIZE_WEB_FRAMEWORK()
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#include <executors/executor.h>

typedef struct json_executor
{
json_object_t items;
size_t size;
} json_executor_t;

DEFINE_EXECUTOR(json_executor_t, STATELESS_EXECUTOR)

DEFINE_EXECUTOR_INIT(json_executor_t)
{
json_executor_t* self = (json_executor_t*)executor;
char* data;
size_t size;

wf_get_file_executor_settings(settings, "dataset.json", &data, &size);

json_parser_t parser;
json_object_t parsed_data;

wf_create_json_parser_from_string(data, &parser);
wf_create_json_object(&self->items);

wf_get_json_parser_parsed_data(parser, &parsed_data, true);
wf_copy_json_object_array(&parsed_data, &self->items, &self->size);

free(data);
wf_delete_json_parser(parser);
}

DEFINE_EXECUTOR_METHOD(json_executor_t, GET_METHOD, request, response)
{
json_executor_t* self = (json_executor_t*)executor;
query_parameter_t* query_parameters;
size_t size;
int64_t count = 0;
int64_t multiplier = 0;
json_builder_t result;

wf_create_json_builder(&result);

wf_get_query_parameters(request, &query_parameters, &size);

for (size_t i = 0; i < size; i++)
{
if (!strcmp(query_parameters[i].key, "m"))
{
multiplier = atoll(query_parameters[i].value);

break;
}
}

wf_get_route_integer_parameter(request, "count", &count);

json_object_t* array = (json_object_t*)malloc(sizeof(json_object_t) * count);

for (int i = 0; i < count; i++)
{
json_object_t temp;
int64_t calculated;

{
json_object_t item;

wf_index_access_json_object_array(&self->items, i, &item);

wf_copy_json_object(&temp, &item);
}

{
json_object_t current;

wf_assign_or_get_json_object(&temp, "price", &current);
wf_get_json_object_integer(&current, &calculated);
}


{
json_object_t current;
int64_t value;

wf_assign_or_get_json_object(&temp, "quantity", &current);
wf_get_json_object_integer(&current, &value);

calculated *= value;
}

calculated *= multiplier;

{
json_object_t total;

wf_assign_or_get_json_object(&temp, "total", &total);

wf_set_json_object_integer(&total, calculated);
}

array[i] = temp;
}

wf_append_json_builder_integer(result, "count", count);
wf_append_json_builder_array(result, "items", array, count);

wf_set_json_body(response, result);

free(query_parameters);

for (int i = 0; i < count; i++)
{
wf_delete_json_object(&array[i]);
}

free(array);

wf_delete_json_builder(result);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <executors/executor.h>

DEFINE_DEFAULT_EXECUTOR(pipeline_t, STATELESS_EXECUTOR)

DEFINE_EXECUTOR_METHOD(pipeline_t, GET_METHOD, request, response)
{
const char ok[] = "ok";

wf_set_body(response, ok, strlen(ok));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include <executors/executor.h>

#define THRESHOLD_SIZE 102400

typedef struct upload
{
int current_size;
} upload_t;

DEFINE_EXECUTOR(upload_t, STATEFUL_EXECUTOR)

DEFINE_EXECUTOR_INIT(upload_t)
{
((upload_t*)executor)->current_size = 0;
}

DEFINE_EXECUTOR_METHOD(upload_t, POST_METHOD, request, response)
{
upload_t* self = (upload_t*)executor;
const char* contentLength;

wf_get_http_header(request, "Content-Length", &contentLength);

if (atoi(contentLength) >= THRESHOLD_SIZE)
{
const large_data_t* data = NULL;

wf_get_large_data(request, &data);

self->current_size += data->data_part_size;

if (data->is_last_packet)
{
char buffer[32];

memset(buffer, 0, sizeof(buffer));

snprintf(buffer, sizeof(buffer), "%d", self->current_size);

wf_set_body(response, buffer, sizeof(buffer));
}
}
else
{
const char* body;
size_t size;

wf_get_http_body(request, &body, &size);

self->current_size += size;

char buffer[32];

memset(buffer, 0, sizeof(buffer));

snprintf(buffer, sizeof(buffer), "%d", self->current_size);

wf_set_body(response, buffer, sizeof(buffer));
}
}
Loading