Skip to content

Commit 8d3491f

Browse files
committed
docs: Add the v1.1.0 benchmark results to README
1 parent 1eddec8 commit 8d3491f

File tree

4 files changed

+76
-43
lines changed

4 files changed

+76
-43
lines changed

README.md

Lines changed: 76 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ SafeBox can help you [migrate](docs/MIGRATION.md) easily using the same `SharedP
99

1010
## Why SafeBox?
1111

12-
| Feature | SafeBox | EncryptedSharedPreferences |
12+
| Feature | SafeBox v1.1.0 | EncryptedSharedPreferences |
1313
|---------------------|-----------------------------------|-------------------------------------------|
14-
| Initialization Time | **0.35ms** (*110x faster*) | 38.7ms |
14+
| Initialization Time | **0.38ms** (*100x faster*) | 38.7ms |
1515
| Storage Format | Memory-mapped binary file | XML-based per-entry |
1616
| Encryption Method | ChaCha20-Poly1305 (keys & values) | AES-SIV for keys, AES-GCM for values |
1717
| Key Security | Android Keystore-backed AES-GCM | Android Keystore MasterKey (*deprecated*) |
18-
| Customization | Pluggable cipher/key providers | Tightly coupled |
18+
| Customization | Pluggable cipher providers | Tightly coupled |
1919

2020
SafeBox uses **deterministic encryption** for reference keys (for fast lookup) and **non-deterministic encryption** for values (for strong security). Both powered by a single ChaCha20 key protected via AES-GCM and stored securely.
2121

@@ -41,42 +41,6 @@ Compared to EncryptedSharedPreferences:
4141
4242
```
4343

44-
## Performance Benchmarks
45-
46-
Average times measured over **100 samples** on an emulator:
47-
48-
![Read Performance](docs/charts/read_performance_chart.png)
49-
50-
![Write Performance](docs/charts/write_performance_chart.png)
51-
52-
![Write then Commit Performance](docs/charts/write_commit_performance_chart.png)
53-
54-
<details>
55-
56-
<summary>📊 Comparison Tables</summary>
57-
58-
| Operation | SafeBox | EncryptedSharedPreferences |
59-
|------------------------------|------------|----------------------------|
60-
| Write 1 entry then commit | **0.55ms** | 1.31ms (*138% slower*) |
61-
| Read 1 entry | **0.39ms** | 0.50ms (*28% slower*) |
62-
| Write 3 entries then commit | **1.25ms** | 2.16ms (*73% slower*) |
63-
| Read 3 entries | **0.94ms** | 1.27ms (*35% slower*) |
64-
| Write 5 entries then commit | **2.33ms** | 3.32ms (*42% slower*) |
65-
| Read 5 entries | **1.37ms** | 2.25ms (*64% slower*) |
66-
| Write 10 entries then commit | **4.73ms** | 6.28ms (*33% slower*) |
67-
| Read 10 entries | **3.29ms** | 4.07ms (*24% slower*) |
68-
69-
Even on **multiple single commits**, SafeBox remains faster:
70-
71-
| Operation | SafeBox | EncryptedSharedPreferences |
72-
|------------------------------|-------------|----------------------------|
73-
| Write and commit 3 entries | **1.94ms** | 4.9ms (*152% slower*) |
74-
| Write and commit 5 entries | **2.84ms** | 6.91ms (*143% slower*) |
75-
| Write and commit 10 entries | **5.47ms** | 11.27ms (*106% slower*) |
76-
| Write and commit 100 entries | **33.19ms** | 71.34ms (*115% slower*) |
77-
78-
</details>
79-
8044
## Installation
8145

8246
```kotlin
@@ -175,10 +139,10 @@ Manually add listeners by file name:
175139
```kotlin
176140
val listener = SafeBoxStateListener { state ->
177141
when (state) {
178-
STARTING -> trackStart() // Loading data into memory
179-
IDLE -> trackIdle() // No active operations
180-
WRITING -> trackWrite() // Writing to disk
181-
CLOSED -> trackClose() // Instance is no longer usable
142+
STARTING -> doSomething() // Loading data into memory
143+
IDLE -> doSomething() // No active operations
144+
WRITING -> doSomething() // Writing to disk
145+
CLOSED -> doSomething() // Instance is no longer usable
182146
}
183147
}
184148
SafeBoxGlobalStateObserver.addListener(PREF_FILE_NAME, listener)
@@ -202,6 +166,75 @@ SafeBox is a drop-in replacement for `EncryptedSharedPreferences`.
202166

203167
➡️ [Read the Migration Guide](docs/MIGRATION.md)
204168

169+
## Performance Benchmarks
170+
171+
Average times measured over **100 samples** on an emulator:
172+
173+
<details open>
174+
175+
<summary>📊 v1.1.0 Benchmark</summary>
176+
177+
![Get Performance](docs/charts/v1_1_get_performance_chart.png)
178+
179+
![Put Performance](docs/charts/v1_1_put_performance_chart.png)
180+
181+
![Put then Commit Performance](docs/charts/v1_1_put_and_commit_performance_chart.png)
182+
183+
| Operation | SafeBox v1.1.0 | EncryptedSharedPreferences |
184+
|-----------------------------|----------------|----------------------------|
185+
| Initialization | **0.38ms** | 38.7ms (*10,079% slower*) |
186+
| Get 1 entry | **0.33ms** | 0.50ms (*52% slower*) |
187+
| Get 3 entries | **0.94ms** | 1.27ms (*35% slower*) |
188+
| Get 5 entries | **1.56ms** | 2.25ms (*44% slower*) |
189+
| Get 10 entries | **3.06ms** | 4.07ms (*33% slower*) |
190+
| Put 1 entry, then commit | **0.49ms** | 1.31ms (*167% slower*) |
191+
| Put 3 entries, then commit | **1.34ms** | 2.16ms (*61% slower*) |
192+
| Put 5 entries, then commit | **2.36ms** | 3.32ms (*41% slower*) |
193+
| Put 10 entries, then commit | **4.20ms** | 6.28ms (*50% slower*) |
194+
195+
Even on **multiple single commits**, SafeBox remains faster:
196+
197+
| Operation | SafeBox v1.1.0 | EncryptedSharedPreferences |
198+
|------------------------------|----------------|----------------------------|
199+
| Commit 3 single entries | **1.50ms** | 4.90ms (*227% slower*) |
200+
| Commit 5 single entries | **2.39ms** | 6.91ms (*189% slower*) |
201+
| Commit 10 single entries | **5.07ms** | 11.27ms (*122% slower*) |
202+
| Commit 100 single entries | **38.12ms** | 71.34ms (*87% slower*) |
203+
204+
</details>
205+
206+
<details>
207+
208+
<summary>📊 v1.0.0 Benchmark</summary>
209+
210+
![Get Performance](docs/charts/read_performance_chart.png)
211+
212+
![Put Performance](docs/charts/write_performance_chart.png)
213+
214+
![Put then Commit Performance](docs/charts/write_commit_performance_chart.png)
215+
216+
| Operation | SafeBox v1.0.0 | EncryptedSharedPreferences |
217+
|-----------------------------|----------------|----------------------------|
218+
| Get 1 entry | **0.39ms** | 0.50ms (*28% slower*) |
219+
| Get 3 entries | **0.94ms** | 1.27ms (*35% slower*) |
220+
| Get 5 entries | **1.37ms** | 2.25ms (*64% slower*) |
221+
| Get 10 entries | **3.29ms** | 4.07ms (*24% slower*) |
222+
| Put 1 entry, then commit | **0.55ms** | 1.31ms (*138% slower*) |
223+
| Put 3 entries, then commit | **1.25ms** | 2.16ms (*73% slower*) |
224+
| Put 5 entries, then commit | **2.33ms** | 3.32ms (*42% slower*) |
225+
| Put 10 entries, then commit | **4.73ms** | 6.28ms (*33% slower*) |
226+
227+
Even on **multiple single commits**, SafeBox remains faster:
228+
229+
| Operation | SafeBox v1.0.0 | EncryptedSharedPreferences |
230+
|------------------------------|----------------|----------------------------|
231+
| Commit 3 single entries | **1.94ms** | 4.90ms (*152% slower*) |
232+
| Commit 5 single entries | **2.84ms** | 6.91ms (*143% slower*) |
233+
| Commit 10 single entries | **5.47ms** | 11.27ms (*106% slower*) |
234+
| Commit 100 single entries | **33.19ms** | 71.34ms (*115% slower*) |
235+
236+
</details>
237+
205238
## Contributing
206239

207240
See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, formatting, testing, and PR guidelines.
114 KB
Loading
116 KB
Loading
101 KB
Loading

0 commit comments

Comments
 (0)