fix: bloat
This commit is contained in:
parent
86f036d8cc
commit
bb57a25416
9 changed files with 8 additions and 66 deletions
|
@ -95,7 +95,7 @@ http::run "$@"
|
|||
# ⚡ Benchmarks
|
||||
It's... bad 🥲
|
||||
|
||||
All benchmarks were conducted on an i7-1360P laptop with 16GB of RAM using the tool codesenberg/bombardier. The benchmark folder in the repository contains all the source files used for benchmarking, along with a run.sh script to automate the benchmarking process. Here are the detailed results:
|
||||
All benchmarks were conducted on an i7-1360P laptop with 16GB of RAM using the tool codesenberg/bombardier. Here are the detailed results:
|
||||
|
||||
### python3 -m http.server
|
||||
```
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
flask
|
||||
gunicorn
|
|
@ -1,28 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -m
|
||||
|
||||
install_gunicorn() {
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install gunicorn
|
||||
}
|
||||
|
||||
declare -a reqs=('node' 'python3' 'go')
|
||||
declare -A run_cmds=([8082]='go run test.go' [8083]='node test.js' [8084]='gunicorn -w 8 test:app -b localhost:8084' [8000]='python3 -m http.server' [8081]='bash ./test.sh run')
|
||||
|
||||
for package in "${reqs[@]}"; do
|
||||
command -v "${package}" >/dev/null || { echo "Error! ${package} is not installed on this system."; exit 1; }
|
||||
done
|
||||
|
||||
command -v bombardier >/dev/null || go install github.com/codesenberg/bombardier@latest
|
||||
command -v gunicorn >/dev/null || install_gunicorn >/dev/null
|
||||
|
||||
for port in "${!run_cmds[@]}"; do
|
||||
echo "Running: ${run_cmds[$port]}"
|
||||
${run_cmds[$port]} >/dev/null 2>&1 & pid="$!"
|
||||
sleep 0.5
|
||||
bombardier -d 30s http://127.0.0.1:"$port"
|
||||
kill -TERM -- -"$pid"
|
||||
done
|
|
@ -1,6 +0,0 @@
|
|||
package main
|
||||
import ( "net/http")
|
||||
func main() {
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("{}")) });
|
||||
http.ListenAndServe(":8082", nil);
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
const http = require('http');
|
||||
const server = http.createServer((req, res) => {
|
||||
res.statusCode = 200;
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end("{}");
|
||||
});
|
||||
server.listen(8083);
|
|
@ -1,7 +0,0 @@
|
|||
from flask import Flask
|
||||
|
||||
app = Flask('app')
|
||||
|
||||
@app.get("/")
|
||||
def root():
|
||||
return "{}"
|
|
@ -1,9 +0,0 @@
|
|||
. ../src/http_server.sh
|
||||
|
||||
http::bind "127.0.0.1" "8081"
|
||||
|
||||
main() {
|
||||
http::response 200
|
||||
} && http::get main "/"
|
||||
|
||||
http::run "$@"
|
|
@ -39,9 +39,8 @@ http::run() {
|
|||
|
||||
http::host() { export HTTP_HOST_NAME="$1"; }
|
||||
http::bind() { export HTTP_HOST="${1:-${HTTP_DEFAULT_HOST}}"; export HTTP_PORT="${2:-${HTTP_DEFAULT_PORT}}"; }
|
||||
http::markdown_base() { export HTTP_MARKDOWN_BASE="$1"; }
|
||||
|
||||
http::static_folder() {
|
||||
http::static_folder() { # TODO add multiple static folders
|
||||
http__handlers["GET,$1/**"]="http::_static_file"
|
||||
http__all_routes["$1/**"]=1
|
||||
export HTTP_STATIC_FOLDER="$2";
|
||||
|
|
|
@ -5,14 +5,16 @@ export HTTP_GUARD__MARKDOWN_SH=''
|
|||
|
||||
|
||||
http::_convert_to_md() {
|
||||
local -a pandoc_options=(
|
||||
'--from=gfm+tex_math_dollars '
|
||||
'--to=html'
|
||||
local -a _pandoc_options=(
|
||||
'--from=gfm+tex_math_dollars+footnotes+emoji-autolink_bare_uris'
|
||||
'--to=html+raw_html'
|
||||
'--mathjax'
|
||||
'--toc'
|
||||
"--template=${HTTP_MARKDOWN_BASE:-'default.html5'}"
|
||||
"--variable=published_time=$(date -Iseconds -d"$(stat "$1" | grep 'Birth:' | sed 's/.*Birth:\s//')")"
|
||||
"${pandoc_options[@]}"
|
||||
)
|
||||
pandoc "${pandoc_options[@]}" "$1"
|
||||
pandoc "${_pandoc_options[@]}" "$1"
|
||||
}
|
||||
|
||||
http::md() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue