Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.
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
4 changes: 2 additions & 2 deletions frameworks/Rust/sib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sib-techempower"
version = "0.0.2"
version = "0.0.3"
authors = ["mail@pooya.ai"]
description = "A high-performance, secure, and cross-platform modules optimized for efficiency, scalability, and reliability."
documentation = "https://docs.rs/sib"
Expand All @@ -16,7 +16,7 @@ sib = { version = "0.0.17", default-features = false, features = [
"net-h1-server",
] }
bytes = { version = "1.11.1", default-features = false }
heapless = { version = "0.9.1", default-features = false }
http = { version = "1.4.0", default-features = false, features = ["std"] }
mimalloc = { version = "0.1.48", default-features = false, features = [
"secure",
] }
Expand Down
4 changes: 2 additions & 2 deletions frameworks/Rust/sib/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"json_url": "/json",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Stripped",
"approach": "Realistic",
"classification": "Fullstack",
"framework": "sib",
"language": "Rust",
Expand All @@ -21,4 +21,4 @@
}
}
]
}
}
58 changes: 22 additions & 36 deletions frameworks/Rust/sib/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// TechEmpower benchmark tests for Sib with the `net-h1-server` feature enabled

use bytes::Bytes;
use http::StatusCode;
use sib::network::http::{
server::{H1Config, HFactory},
session::{HService, Session},
Expand All @@ -8,6 +9,8 @@ use sib::network::http::{
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

const PLAINTEXT_BODY: &[u8] = b"Hello, World!";
const PLAINTEXT_CONTENT_LENGTH: &str = "13";
#[derive(serde::Serialize)]
struct JsonMessage<'a> {
message: &'a str,
Expand All @@ -25,41 +28,24 @@ struct Server;

impl HService for Server {
fn call<S: Session>(&mut self, session: &mut S) -> std::io::Result<()> {
use core::fmt::Write;
let time = sib::network::http::date::current_date_str();
let mut res: heapless::String<256> = heapless::String::new();
if session.req_path_bytes() == b"/json" {
// Respond with JSON
let json = serde_json::to_vec(&JsonMessage::default())?;
write!(
res,
"HTTP/1.1 200 OK\r\n\
Server: sib\r\n\
Date: {}\r\n\
Content-Type: application/json\r\n\
Content-Length: {}\r\n\
\r\n\
{}",
time,
&json.len().to_string(),
String::from_utf8_lossy(&json)
)
.unwrap();
session.write_all_eom(res.as_bytes())
} else {
write!(
res,
"HTTP/1.1 200 OK\r\n\
Server: sib\r\n\
Date: {}\r\n\
Content-Type: text/plain\r\n\
Content-Length: 13\r\n\
\r\n\
Hello, World!",
time
)
.unwrap();
session.write_all_eom(res.as_bytes())
match session.req_path_bytes() {
b"/json" => {
let json = serde_json::to_vec(&JsonMessage::default())?;
let json_len = json.len().to_string();

session
.status_code(StatusCode::OK)
.header_str("Content-Type", "application/json")?
.header_str("Content-Length", json_len.as_str())?
.body(json.into())
.eom()
}
_ => session
.status_code(StatusCode::OK)
.header_str("Content-Type", "text/plain")?
.header_str("Content-Length", PLAINTEXT_CONTENT_LENGTH)?
.body(Bytes::from_static(PLAINTEXT_BODY))
.eom(),
}
}
}
Expand Down
Loading