diff --git a/benchmarks/.gitignore b/benchmarks/.gitignore new file mode 100644 index 0000000..061c12b --- /dev/null +++ b/benchmarks/.gitignore @@ -0,0 +1 @@ +_output/ \ No newline at end of file diff --git a/benchmarks/README.md b/benchmarks/README.md new file mode 100644 index 0000000..38b355b --- /dev/null +++ b/benchmarks/README.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/benchmarks/ewe/.github/workflows/test.yml b/benchmarks/ewe/.github/workflows/test.yml new file mode 100644 index 0000000..f6e42b5 --- /dev/null +++ b/benchmarks/ewe/.github/workflows/test.yml @@ -0,0 +1,23 @@ +name: test + +on: + push: + branches: + - master + - main + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: erlef/setup-beam@v1 + with: + otp-version: "28" + gleam-version: "1.13.0" + rebar3-version: "3" + # elixir-version: "1" + - run: gleam deps download + - run: gleam test + - run: gleam format --check src test diff --git a/benchmarks/ewe/.gitignore b/benchmarks/ewe/.gitignore new file mode 100644 index 0000000..599be4e --- /dev/null +++ b/benchmarks/ewe/.gitignore @@ -0,0 +1,4 @@ +*.beam +*.ez +/build +erl_crash.dump diff --git a/benchmarks/ewe/README.md b/benchmarks/ewe/README.md new file mode 100644 index 0000000..6936098 --- /dev/null +++ b/benchmarks/ewe/README.md @@ -0,0 +1,24 @@ +# app + +[![Package Version](https://img.shields.io/hexpm/v/app)](https://hex.pm/packages/app) +[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/app/) + +```sh +gleam add app@1 +``` +```gleam +import app + +pub fn main() -> Nil { + // TODO: An example of the project in use +} +``` + +Further documentation can be found at . + +## Development + +```sh +gleam run # Run the project +gleam test # Run the tests +``` diff --git a/benchmarks/ewe/gleam.toml b/benchmarks/ewe/gleam.toml new file mode 100644 index 0000000..5b555b8 --- /dev/null +++ b/benchmarks/ewe/gleam.toml @@ -0,0 +1,22 @@ +name = "app" +version = "1.0.0" + +# Fill out these fields if you intend to generate HTML documentation or publish +# your project to the Hex package manager. +# +# description = "" +# licences = ["Apache-2.0"] +# repository = { type = "github", user = "", repo = "" } +# links = [{ title = "Website", href = "" }] +# +# For a full reference of all the available options, you can have a look at +# https://gleam.run/writing-gleam/gleam-toml/. + +[dependencies] +gleam_stdlib = ">= 0.44.0 and < 2.0.0" +ewe = ">= 2.0.2 and < 3.0.0" +gleam_http = ">= 4.3.0 and < 5.0.0" +gleam_erlang = ">= 1.3.0 and < 2.0.0" + +[dev-dependencies] +gleeunit = ">= 1.0.0 and < 2.0.0" diff --git a/benchmarks/ewe/manifest.toml b/benchmarks/ewe/manifest.toml new file mode 100644 index 0000000..cfe3f21 --- /dev/null +++ b/benchmarks/ewe/manifest.toml @@ -0,0 +1,25 @@ +# This file was generated by Gleam +# You typically do not need to edit this file + +packages = [ + { name = "compresso", version = "0.1.0", build_tools = ["gleam"], requirements = ["exception", "gleam_erlang", "gleam_stdlib", "gleam_yielder", "logging"], otp_app = "compresso", source = "hex", outer_checksum = "8BE29A1EDA42F70826ED148EAE40C46BB3FC18E78FE472663DB01DD4A38172D4" }, + { name = "ewe", version = "2.0.2", build_tools = ["gleam"], requirements = ["compresso", "gleam_crypto", "gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "glisten", "logging"], otp_app = "ewe", source = "hex", outer_checksum = "55FABC310F9C0EC67021F6CA973ED59A37481E39E6A850813D5B6F4CEA241A68" }, + { name = "exception", version = "2.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "329D269D5C2A314F7364BD2711372B6F2C58FA6F39981572E5CA68624D291F8C" }, + { name = "gleam_crypto", version = "1.5.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_crypto", source = "hex", outer_checksum = "50774BAFFF1144E7872814C566C5D653D83A3EBF23ACC3156B757A1B6819086E" }, + { name = "gleam_erlang", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "1124AD3AA21143E5AF0FC5CF3D9529F6DB8CA03E43A55711B60B6B7B3874375C" }, + { name = "gleam_http", version = "4.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "82EA6A717C842456188C190AFB372665EA56CE13D8559BF3B1DD9E40F619EE0C" }, + { name = "gleam_otp", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "BA6A294E295E428EC1562DC1C11EA7530DCB981E8359134BEABC8493B7B2258E" }, + { name = "gleam_stdlib", version = "0.65.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "7C69C71D8C493AE11A5184828A77110EB05A7786EBF8B25B36A72F879C3EE107" }, + { name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" }, + { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" }, + { name = "glisten", version = "8.0.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "logging", "telemetry"], otp_app = "glisten", source = "hex", outer_checksum = "534BB27C71FB9E506345A767C0D76B17A9E9199934340C975DC003C710E3692D" }, + { name = "logging", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "1098FBF10B54B44C2C7FDF0B01C1253CAFACDACABEFB4B0D027803246753E06D" }, + { name = "telemetry", version = "1.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "telemetry", source = "hex", outer_checksum = "7015FC8919DBE63764F4B4B87A95B7C0996BD539E0D499BE6EC9D7F3875B79E6" }, +] + +[requirements] +ewe = { version = ">= 2.0.2 and < 3.0.0" } +gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" } +gleeunit = { version = ">= 1.0.0 and < 2.0.0" } +gleam_http = { version = ">= 4.3.0 and < 5.0.0" } +gleam_erlang = { version = ">= 1.3.0 and < 2.0.0" } diff --git a/benchmarks/ewe/src/app.gleam b/benchmarks/ewe/src/app.gleam new file mode 100644 index 0000000..6eec0dc --- /dev/null +++ b/benchmarks/ewe/src/app.gleam @@ -0,0 +1,23 @@ +import ewe +import gleam/erlang/process +import gleam/http/request +import gleam/http/response + +pub fn main() -> Nil { + let assert Ok(_started) = + ewe.new(fn(req) { + case request.path_segments(req) { + ["hello"] -> + response.new(200) + |> response.set_header("content-type", "text/plain; charset=utf-8") + |> response.set_body(ewe.TextData("Hello, World!")) + + _ -> response.new(404) |> response.set_body(ewe.Empty) + } + }) + |> ewe.bind_all() + |> ewe.listening(port: 8080) + |> ewe.start() + + process.sleep_forever() +} diff --git a/benchmarks/exec.sh b/benchmarks/exec.sh new file mode 100755 index 0000000..425303b --- /dev/null +++ b/benchmarks/exec.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +target=http://0.0.0.0:8080 + +h2load --h1 --no-tls-proto=http/1.1 -D 30 "$target/hello" -t 12 -c 12 > "_output/ewe.txt" \ No newline at end of file diff --git a/gleam.toml b/gleam.toml index dee1164..d2134d9 100644 --- a/gleam.toml +++ b/gleam.toml @@ -14,9 +14,9 @@ links = [ gleam_stdlib = ">= 0.44.0 and < 2.0.0" glisten = ">= 8.0.1 and < 9.0.0" gleam_otp = ">= 1.1.0 and < 2.0.0" -gleam_http = ">= 4.1.1 and < 5.0.0" +gleam_http = ">= 4.3.0 and < 5.0.0" logging = ">= 1.3.0 and < 2.0.0" -gleam_erlang = ">= 1.2.0 and < 2.0.0" +gleam_erlang = ">= 1.3.0 and < 2.0.0" gleam_crypto = ">= 1.5.1 and < 2.0.0" compresso = "0.1.0" # gramps = ">= 6.0.0 and < 7.0.0" diff --git a/manifest.toml b/manifest.toml index 663bd6e..6d50e6a 100644 --- a/manifest.toml +++ b/manifest.toml @@ -21,8 +21,8 @@ packages = [ [requirements] compresso = { version = "0.1.0" } gleam_crypto = { version = ">= 1.5.1 and < 2.0.0" } -gleam_erlang = { version = ">= 1.2.0 and < 2.0.0" } -gleam_http = { version = ">= 4.1.1 and < 5.0.0" } +gleam_erlang = { version = ">= 1.3.0 and < 2.0.0" } +gleam_http = { version = ">= 4.3.0 and < 5.0.0" } gleam_httpc = { version = ">= 5.0.0 and < 6.0.0" } gleam_json = { version = ">= 3.0.2 and < 4.0.0" } gleam_otp = { version = ">= 1.1.0 and < 2.0.0" }