# mORMot Benchmarking Test

This is a framework implementation using the [mORMot2](https://github.com/synopse/mORMot2) FreePascal/Delphi framework.
It builds using [FreePascal](https://www.freepascal.org/) compiler and developed using [Lazarus IDE](https://www.lazarus-ide.org/)

### Test Type Implementation Source Code

* [ORM and RAW implementation for all tests](src/raw.pas)

## Important Libraries
The tests were run with:
* [mORMot2 latest](https://github.com/synopse/mORMot2)
* [FreePascal 3.2.2](https://www.freepascal.org/)

## Contributor tips
For debugging purpose run Postges using Docker
```shell
sudo docker run --name postgres -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 postgres:12
```
add `tfb-database` into hosts
```shell
echo '127.0.0.1	 tfb-database' | sudo tee -a /etc/hosts
```

Database can be initialized using scripts from [TFBDatabases repo](https://github.com/TechEmpower/TFBDatabases)

```shell
git clone https://github.com/TechEmpower/TFBDatabases.git
cd TFBDatabases
psql postgres://postgres:postgres@tfb-database:5432 < create-postgres-database.sql
psql postgres://benchmarkdbuser:benchmarkdbpass@tfb-database:5432/hello_world < create-postgres.sql
```

## Test URLs

### JSON

http://localhost:8080/json

### PLAINTEXT

http://localhost:8080/plaintext

`mORMot` HTTP server does not support [HTTP pipelining](https://developer.mozilla.org/en-US/docs/Web/HTTP/Connection_management_in_HTTP_1.x#http_pipelining),
so numbers is not impressive here.

### DB

http://localhost:8080/db

### QUERY

http://localhost:8080/query?queries=

### CACHED QUERY

http://localhost:8080/cached_query?queries=

### UPDATE

http://localhost:8080/update?queries=

Batch update SQL statement in case of Postgres is generated by ORM as such:
```sql
update table set field = v.field from (SELECT unnest(?), unnest(?)) as v(id, field) where t.id = v.id
```
Nested select is a reason of warning for `tfb --verify`

### FORTUNES

http://localhost:8080/fortunes

