S-YOU 5 years ago
parent
commit
78086ac1aa

+ 1 - 0
.travis.yml

@@ -80,6 +80,7 @@ env:
     - "TESTLANG=Swift"
     - "TESTLANG=TypeScript"
     - "TESTLANG=Ur"
+    - "TESTLANG=V"
     - "TESTLANG=Vala"
     - "TESTLANG=VB"
 

+ 21 - 0
frameworks/V/pico.v/README.md

@@ -0,0 +1,21 @@
+# pico.v Benchmarking Test
+
+### Test Type Implementation Source Code
+
+* [JSON](main.v)
+* [PLAINTEXT](main.v)
+
+## Important Libraries
+The tests were run with:
+* [V](https://vlang.io)
+* [picoev](https://github.com/kazuho/picoev)
+* [picohttpparser](https://github.com/h2o/picohttpparser/)
+
+## Test URLs
+### JSON
+
+http://localhost:8080/json
+
+### PLAINTEXT
+
+http://localhost:8080/plaintext

+ 26 - 0
frameworks/V/pico.v/benchmark_config.json

@@ -0,0 +1,26 @@
+{
+  "framework": "pico.v",
+  "tests": [
+    {
+      "default": {
+        "json_url": "/j",
+        "plaintext_url": "/t",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Micro",
+        "database": "None",
+        "framework": "pico.v",
+        "language": "V",
+        "flavor": "None",
+        "orm": "None",
+        "platform": "None",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "pico.v",
+        "notes": "",
+        "versus": "None"
+      }
+    }
+  ]
+}

+ 36 - 0
frameworks/V/pico.v/main.v

@@ -0,0 +1,36 @@
+import json
+import syou.picoev
+import syou.picohttpparser as hp
+
+struct Message {
+	message string
+}
+
+[inline]
+fn json_response() string {
+	msg := Message{message: "Hello, World!"}
+	return json.encode(msg)
+}
+
+[inline]
+fn hello_response() string {
+	return "Hello, World!"
+}
+
+pub fn callback(req hp.Request, res mut hp.Response) {
+	if hp.cmp(req.method, "GET") {
+		if hp.cmp(req.path, "/t") {
+			res.http_ok().header_server().header_date().plain().body(hello_response())
+		} else if hp.cmp(req.path, "/j") {
+			res.http_ok().header_server().header_date().json().body(json_response())
+		} else {
+			res.http_404()
+		}
+	} else {
+		res.http_405()
+	}
+}
+
+pub fn main() {
+	picoev.new(8080, &callback).serve()
+}

+ 15 - 0
frameworks/V/pico.v/pico.v.dockerfile

@@ -0,0 +1,15 @@
+FROM debian:sid
+
+WORKDIR /app
+
+RUN apt-get update -yqq && apt-get install wget unzip build-essential ca-certificates git --no-install-recommends --yes -yqq
+RUN wget -q https://github.com/vlang/v/releases/download/0.1.24/v_linux.zip && unzip -q v_linux.zip -d ./v/ && rm v_linux.zip
+
+COPY ./main.v run.sh ./
+
+RUN git clone https://github.com/S-YOU/pico.v src && cd src && git checkout v0.0.3
+RUN cd src/picoev && git clone https://github.com/S-YOU/picoev src && cd src && git checkout 311fb2c2a148baca7b7fad33afa94e4558c63478
+RUN cd src/picohttpparser && git clone https://github.com/h2o/picohttpparser src && cd src && git checkout 81fe3d99fd90a55cafb993e53fd3000dbc4d564c
+RUN mkdir -p /root/.vmodules/ && ln -s /app/src /root/.vmodules/syou && ./v/v -prod -cflags '-std=gnu11 -Wall -O3 -march=native -mtune=native -flto' main.v
+
+CMD sh run.sh

+ 7 - 0
frameworks/V/pico.v/run.sh

@@ -0,0 +1,7 @@
+#!/bin/sh
+
+for i in $(seq 0 $(($(nproc --all)-1))); do
+  taskset -c $i ./main &
+done
+
+wait