11# Vix.cpp
22
33<p align =" center " style =" margin :0 ;" >
4- <img
5- src="https://res.cloudinary.com/dwjbed2xb/image/upload/v1762524350/vixcpp_etndhz.png "
6- alt="Vix.cpp Banner"
7- width="100%"
4+ <img
5+ src="https://res.cloudinary.com/dwjbed2xb/image/upload/v1762524350/vixcpp_etndhz.png "
6+ alt="Vix.cpp Banner"
7+ width="100%"
88 style="
99 display: block ;
1010 height: auto ;
3232
3333目標は明確です。
3434
35- > ** Node / Deno / Bun のようなアプリを実行でき、
35+ > ** Node / Deno / Bun のようなアプリを実行でき、
3636> しかも不安定で低品質な「現実世界のネットワーク」を前提に設計されたランタイム**
3737
38- Vix は単なるバックエンドフレームワークではありません。
38+ Vix は単なるバックエンドフレームワークではありません。
3939これは ** モジュラー構成のランタイム** であり、分散アプリケーション、エッジシステム、オフラインデバイス、そして従来のクラウド前提フレームワークが機能しない環境向けに設計されています。
4040
41- ** FastAPI** , ** Vue.js** , ** React** 、最新のランタイムに着想を得つつ、
41+ ** FastAPI** , ** Vue.js** , ** React** 、最新のランタイムに着想を得つつ、
4242** C++20 によってゼロから再設計** され、圧倒的な速度と完全な制御性を実現しています。
4343
4444---
4545
4646# ⚡ ベンチマーク(更新版 — 二〇二五年 十二月)
4747
48- すべてのベンチマークは ** wrk** を使用して実行されました。
48+ すべてのベンチマークは ** wrk** を使用して実行されました。
4949** 八スレッド / 八百接続 / 三十秒** 、同一マシンで測定しています。
5050
51- ** 環境**
51+ ** 環境**
5252Ubuntu 二十四点〇四 — Intel Xeon — C++20 最適化ビルド — ログ無効
5353
5454結果は ` "OK" ` を返すシンプルなエンドポイントでの ** 定常状態スループット** です。
@@ -68,8 +68,8 @@ Ubuntu 二十四点〇四 — Intel Xeon — C++20 最適化ビルド — ログ
6868| Crow(C++) | 一千百四十九 | 四一・六〇 ms | 〇・三五 MB/s |
6969| FastAPI(Python) | 七百五十二 | 六三・七一 ms | 〇・一一 MB/s |
7070
71- > 🔥 ** 新記録**
72- > 単一コアに固定(` taskset -c 2 ` )した場合、
71+ > 🔥 ** 新記録**
72+ > 単一コアに固定(` taskset -c 2 ` )した場合、
7373> ** 約 九万九千 req/s** に到達し、Go を上回り、最速クラスの C++ マイクロフレームワークに並びました。
7474
7575---
@@ -174,25 +174,31 @@ using namespace vix;
174174
175175int main ()
176176{
177- auto bundle = vix::make_http_and_ws("config/config.json");
178- auto &[app, ws] = bundle;
179-
180- app.get("/", [](const Request &, Response &res)
181- { res.json({"framework", "Vix.cpp",
182- "message", "HTTP + WebSocket example (basic) 🚀"}); });
183-
184- ws.on_open([&ws](auto &session)
185- {
186- (void)session;
187-
188- ws.broadcast_json("chat.system", {
189- "user", "server",
190- "text", "Welcome to Vix WebSocket! 👋"
191- }); });
192-
193- vix::run_http_and_ws (app, ws, 8080);
194-
195- return 0;
177+ // Use default config path "config/config.json" and port 8080
178+ vix::serve_http_and_ws ([ ] (auto &app, auto &ws)
179+ {
180+ // Minimal HTTP route
181+ app.get("/", [ ] (auto&, auto& res) {
182+ res.json({
183+ "message", "Hello from Vix.cpp minimal example 👋",
184+ "framework", "Vix.cpp"
185+ });
186+ });
187+
188+ // Minimal WebSocket handler: log and echo chat.message
189+ ws.on_typed_message(
190+ [&ws](auto& session,
191+ const std::string& type,
192+ const vix::json::kvs& payload)
193+ {
194+ (void)session;
195+
196+ if (type == "chat.message") {
197+ ws.broadcast_json("chat.message", payload);
198+ }
199+ }); });
200+
201+ return 0;
196202}
197203```
198204
@@ -249,10 +255,7 @@ app.get("/search", [](Request req, Response res) {
249255
250256``` cpp
251257app.get(" /missing" , [](Request req, Response res) {
252- return std::pair{
253- 404,
254- json::o ("error", "Not found")
255- };
258+ res.status(404).json({"error", "Not found"});
256259});
257260```
258261
0 commit comments