Skip to content

Commit 0f1888f

Browse files
author
Michael Solomon
authored
Performance Tests - RAM disk (#17)
2 parents 35b0251 + e6f1fe8 commit 0f1888f

File tree

6 files changed

+774
-9
lines changed

6 files changed

+774
-9
lines changed

Diff for: .nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14.15.0

Diff for: example-application/data-access/order-repository.js

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ module.exports = class OrderReposiroty {
2828
}
2929

3030
async addOrder(orderDetails) {
31-
3231
return await orderModel.create(orderDetails);
3332
}
3433
};

Diff for: example-application/test/docker-compose.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "3"
1+
version: "3.6"
22
services:
33
db:
44
image: postgres:11
@@ -10,10 +10,4 @@ services:
1010
container_name: "postgres-for-testing"
1111
ports:
1212
- "54320:5432"
13-
volumes:
14-
- data:/var/lib/postgresql/data
15-
volumes:
16-
data:
17-
driver_opts:
18-
type: tmpfs
19-
device: tmpfs
13+
tmpfs: /var/lib/postgresql/data

Diff for: various-receipes/performance/readme.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Tests Performance
2+
3+
## In-Memory DB
4+
TL;DR: don't bother
5+
6+
A common time-consuming operation on a typical server is database query, and slow tests are bad.
7+
Database queries are expensive, also because the data resides on the drive, which is very slowly relative to other parts of the computer.
8+
One method to speed up the database for testing and local-development is to run the database on RAM, which is way faster than the drive.
9+
10+
But is it worth it? Probably not, and this is why:
11+
1. SSD is pretty much a standard now, and they are blazingly fast compared to the old HHD.
12+
2. It's preferred and easier to configure your database for non-durable settings to reduce database-related I/O drastically.
13+
3. Usually, test scenarios don't involve much data, so the DB's I/O-speed becomes secondary.
14+
4. The performance between in-memory and regular database with the correct settings is neglectable (if any).
15+
Detailed benchmarks and results can be found [here](https://github.com/testjavascript/integration-tests-a-z/issues/9#issuecomment-710674437).

0 commit comments

Comments
 (0)