forked from avinassh/fast-sqlite3-inserts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bench.sh
executable file
·123 lines (107 loc) · 4.97 KB
/
bench.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh
# runs each of the scripts one after another, prints the measurements to stdout
export TZ=":Asia/Kolkata"
# benching naive version
rm -rf naive.db naive.db-shm naive.db-wal
echo "$(date)" "[PYTHON] running naive.py (10_000_000) inserts"
time python3 naive.py
# lets verify the data exists
if [[ $(sqlite3 naive.db "select count(*) from user";) != 10000000 ]]; then
echo "data verification failed"
fi
# benching naive batched
rm -rf naive_batched.db naive_batched.db-shm naive_batched.db-wal
echo
echo "$(date)" "[PYTHON] running naive_batched.py (10_000_000) inserts"
time python3 naive_batched.py
if [[ $(sqlite3 naive_batched.db "select count(*) from user";) != 10000000 ]]; then
echo "data verification failed"
fi
# benching sqlite3 optimized
rm -rf sqlite3_opt.db sqlite3_opt.db-shm sqlite3_opt.db-wal
echo
echo "$(date)" "[PYTHON] running sqlite3_opt.py (100_000_000) inserts"
time python3 sqlite3_opt.py
if [[ $(sqlite3 sqlite3_opt.db "select count(*) from user";) != 100000000 ]]; then
echo "data verification failed"
fi
# benching sqlite3 optimized on PYPY
rm -rf sqlite3_opt.db sqlite3_opt.db-shm sqlite3_opt.db-wal
echo
echo "$(date)" "[PYPY] running sqlite3_opt.py (100_000_000) inserts"
time pypy3 sqlite3_opt.py
if [[ $(sqlite3 sqlite3_opt.db "select count(*) from user";) != 100000000 ]]; then
echo "data verification failed"
fi
# benching sqlite3 optimized and batched
rm -rf sqlite3_opt_batched.db sqlite3_opt_batched.db-shm sqlite3_opt_batched.db-wal
echo
echo "$(date)" "[PYTHON] running sqlite3_opt_batched.py (100_000_000) inserts"
time python3 sqlite3_opt_batched.py
if [[ $(sqlite3 sqlite3_opt_batched.db "select count(*) from user";) != 100000000 ]]; then
echo "data verification failed"
fi
# benching sqlite3 optimized, batched and threaded
rm -rf threaded_batched.db threaded_batched.db-shm threaded_batched.db-wal
echo
echo "$(date)" "[PYTHON] running threaded_batched.py (100_000_000) inserts"
time python3 threaded_batched.py
# this will fail anyways
if [[ $(sqlite3 threaded_batched.db "select count(*) from user";) != 100000000 ]]; then
echo "data verification failed"
fi
# benching sqlite3 optimized, batched, single threaded but on pypy
rm -rf sqlite3_opt_batched.db sqlite3_opt_batched.db-shm sqlite3_opt_batched.db-wal
echo
echo "$(date)" "[PYPY] running sqlite3_opt_batched.py (100_000_000) inserts"
time pypy3 sqlite3_opt_batched.py
if [[ $(sqlite3 sqlite3_opt_batched.db "select count(*) from user";) != 100000000 ]]; then
echo "data verification failed"
fi
# benching sqlite3 optimized, batched, threaded but on pypy
rm -rf threaded_batched.db threaded_batched.db-shm threaded_batched.db-wal
echo
echo "$(date)" "[PYPY] running threaded_batched.py (100_000_000) inserts"
time pypy3 threaded_batched.py
# this will fail anyways
if [[ $(sqlite3 threaded_batched.db "select count(*) from user";) != 100000000 ]]; then
echo "data verification failed"
fi
# benching with all prev sqlite optimisations, but on rust with sqlx async
rm -rf basic_async.db basic_async.db-shm basic_async.db-wal
cargo build --release --quiet --bin basic_async
echo "$(date)" "[RUST] basic_async.rs (100_000_000) inserts"
time ./target/release/basic_async
# benching with all prev sqlite optimisations, but on rust with rusqlite
rm -rf basic.db basic.db-shm basic.db-wal
cargo build --release --quiet --bin basic
echo "$(date)" "[RUST] basic.rs (100_000_000) inserts"
time ./target/release/basic
# benching with all prev sqlite optimisations, but on rust with rusqlite with batched inserts where
# each batch is a really large ass string
rm -rf basic_batched_wp.db basic_batched_wp.db-shm basic_batched_wp.db-wal
cargo build --release --quiet --bin basic_batched_wp
echo "$(date)" "[RUST] basic_batched_wp.rs (100_000_000) inserts"
time ./target/release/basic_batched_wp
# just like the previous version, so really bad.
rm -rf threaded_str_batched.db threaded_str_batched.db-shm threaded_str_batched.db-wal
cargo build --release --quiet --bin threaded_str_batched
echo "$(date)" "[RUST] threaded_str_batched.rs (100_000_000) inserts"
time ./target/release/threaded_str_batched
# benching with all prev sqlite optimisations, but on rust with rusqlite with inserts where
# each batch is a proper prepared statement
rm -rf basic_prep.db basic_prep.db-shm basic_prep.db-wal
cargo build --release --quiet --bin basic_prep
echo "$(date)" "[RUST] basic_prep.rs (100_000_000) inserts"
time ./target/release/basic_prep
# benching with all prev sqlite optimisations, but on rust with rusqlite with batched inserts where
# each batch is a proper prepared statement
rm -rf basic_batched.db basic_batched.db-shm basic_batched.db-wal
cargo build --release --quiet --bin basic_batched
echo "$(date)" "[RUST] basic_batched.rs (100_000_000) inserts"
time ./target/release/basic_batched
# previous version but threaded
rm -rf threaded_batched.db threaded_batched.db-shm threaded_batched.db-wal
cargo build --release --quiet --bin threaded_batched
echo "$(date)" "[RUST] threaded_batched.rs (100_000_000) inserts"
time ./target/release/threaded_batched