Benchmark Rust WebAssembly vs. JavaScript
Build the image with
docker build -t wasm-benchmark .
For local development and testing, the container can easily been started by running
POSTGRES_PASSWORD=yourpassword docker compose up --build
Replace yourpassword
with a random password for the database.
This compose contains its own database, so you don't have to set it up yourself.
The server appears at localhost:80.
Alternatively, to start the container in production,
you have to pass DATABASE_URL
environment variable holding postgres:https://...
URL for the database.
As an example, the start command could look something like this:
docker container run -p 80:80 -e DATABASE_URL=postgres:https://user:[email protected]:5432/mydb wasm-benchmark
To work with this project, you need to have Rust & Cargo and wasm-pack installed.
After cloning this repository run the following commands:
npm install
npx playwright install
npm run build
Create a file called .env
and add your Postgres URL with key DATABASE_URL
.
Then you can run the development server with
npm run dev # frontend
npm run start:dev # backend
or after running npm run build
you can serve the production build with
npm start
Run npm run build
after making changes to rust-lib/
to bring the changes to the server.
Also run npm run build
after any changes to update the production build.
Tests can be run as follows:
npm run test
npm run test:e2e
npm run lint
cargo test --manifest-path rust-lib/Cargo.toml
Finally, you can remove all compiled and derived files by running npm run clean
.
NPM dependencies are should be saved into correct category. Production dependencies are used by the backend. Development dependencies are only used by the frontend (not needed after building) and tests or they are development tools.
JavaScript logo under MIT license from voodootikigod/logo.js.
Rust logo under CC-BY license from rust-lang/rust-artwork.