Skip to content

Commit e5636c9

Browse files
author
MPCoreDeveloper
committed
redesign storage engine
1 parent 4e48427 commit e5636c9

38 files changed

+3669
-2326
lines changed
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
# Analyze Benchmark Results
2+
# Run this AFTER you've run the benchmarks manually
3+
4+
Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan
5+
Write-Host " SharpCoreDB Benchmark Results Analyzer" -ForegroundColor Cyan
6+
Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan
7+
Write-Host ""
8+
9+
# Check if results exist
10+
if (-not (Test-Path "BenchmarkDotNet.Artifacts\results")) {
11+
Write-Host "? No results found!" -ForegroundColor Red
12+
Write-Host ""
13+
Write-Host "Please run benchmarks first:" -ForegroundColor Yellow
14+
Write-Host " 1. Start the benchmark app: dotnet run -c Release" -ForegroundColor White
15+
Write-Host " 2. Choose option 1 or 2" -ForegroundColor White
16+
Write-Host " 3. Wait for completion" -ForegroundColor White
17+
Write-Host " 4. Run this script again" -ForegroundColor White
18+
exit 1
19+
}
20+
21+
# Find most recent markdown files
22+
$mdFiles = Get-ChildItem -Path "BenchmarkDotNet.Artifacts\results" -Filter "*-report-github.md" -File |
23+
Sort-Object LastWriteTime -Descending
24+
25+
if ($mdFiles.Count -eq 0) {
26+
Write-Host "? No markdown result files found!" -ForegroundColor Red
27+
exit 1
28+
}
29+
30+
Write-Host "Found $($mdFiles.Count) result file(s):" -ForegroundColor Green
31+
Write-Host ""
32+
33+
# Show recent results
34+
foreach ($file in $mdFiles | Select-Object -First 5) {
35+
Write-Host "?? $($file.Name)" -ForegroundColor Cyan
36+
Write-Host " Last modified: $($file.LastWriteTime)" -ForegroundColor Gray
37+
Write-Host " Size: $([math]::Round($file.Length / 1KB, 2)) KB" -ForegroundColor Gray
38+
Write-Host ""
39+
}
40+
41+
# Ask which to analyze
42+
Write-Host "Which benchmark do you want to analyze?" -ForegroundColor Yellow
43+
Write-Host ""
44+
Write-Host " 1) Most recent ($(($mdFiles | Select-Object -First 1).Name))" -ForegroundColor White
45+
Write-Host " 2) Show all recent results" -ForegroundColor White
46+
Write-Host " 3) Open results folder" -ForegroundColor White
47+
Write-Host ""
48+
49+
$choice = Read-Host "Enter choice (1-3)"
50+
51+
switch ($choice) {
52+
"1" {
53+
$latest = $mdFiles | Select-Object -First 1
54+
Write-Host ""
55+
Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan
56+
Write-Host " Analysis: $($latest.Name)" -ForegroundColor Cyan
57+
Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan
58+
Write-Host ""
59+
60+
# Read and display content
61+
$content = Get-Content $latest.FullName -Raw
62+
63+
# Extract table
64+
$lines = $content -split "`n"
65+
$inTable = $false
66+
$tableLines = @()
67+
68+
foreach ($line in $lines) {
69+
if ($line -match "^\| Method ") {
70+
$inTable = $true
71+
}
72+
73+
if ($inTable) {
74+
$tableLines += $line
75+
76+
if ($line -notmatch "^\|") {
77+
break
78+
}
79+
}
80+
}
81+
82+
# Display table
83+
if ($tableLines.Count -gt 0) {
84+
Write-Host "?? BENCHMARK RESULTS:" -ForegroundColor Green
85+
Write-Host ""
86+
foreach ($line in $tableLines) {
87+
if ($line -match "Baseline") {
88+
Write-Host $line -ForegroundColor Yellow
89+
}
90+
elseif ($line -match "Optimized") {
91+
Write-Host $line -ForegroundColor Green
92+
}
93+
elseif ($line -match "SQLite") {
94+
Write-Host $line -ForegroundColor Cyan
95+
}
96+
else {
97+
Write-Host $line
98+
}
99+
}
100+
Write-Host ""
101+
}
102+
103+
# Check for issues
104+
if ($content -match "Benchmarks with issues:") {
105+
Write-Host "?? WARNING: Some benchmarks had issues!" -ForegroundColor Red
106+
Write-Host ""
107+
108+
$issuesStart = $content.IndexOf("Benchmarks with issues:")
109+
$issuesSection = $content.Substring($issuesStart).Split("`n") | Select-Object -First 20
110+
111+
foreach ($line in $issuesSection) {
112+
if ($line.Trim()) {
113+
Write-Host " $line" -ForegroundColor Yellow
114+
}
115+
}
116+
Write-Host ""
117+
}
118+
else {
119+
Write-Host "? All benchmarks completed successfully!" -ForegroundColor Green
120+
Write-Host ""
121+
}
122+
123+
# Offer to open HTML report
124+
$htmlFile = $latest.FullName -replace "-github\.md$", ".html"
125+
if (Test-Path $htmlFile) {
126+
$openHtml = Read-Host "Open interactive HTML report? (Y/N)"
127+
if ($openHtml -eq "Y" -or $openHtml -eq "y") {
128+
Start-Process $htmlFile
129+
}
130+
}
131+
}
132+
133+
"2" {
134+
Write-Host ""
135+
Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan
136+
Write-Host " All Recent Results" -ForegroundColor Cyan
137+
Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan
138+
Write-Host ""
139+
140+
foreach ($file in $mdFiles | Select-Object -First 10) {
141+
Write-Host "?? $($file.Name)" -ForegroundColor Cyan
142+
Write-Host " Modified: $($file.LastWriteTime)" -ForegroundColor Gray
143+
Write-Host " Path: $($file.FullName)" -ForegroundColor DarkGray
144+
Write-Host ""
145+
}
146+
}
147+
148+
"3" {
149+
Write-Host ""
150+
Write-Host "Opening results folder..." -ForegroundColor Cyan
151+
Start-Process "BenchmarkDotNet.Artifacts\results"
152+
}
153+
154+
default {
155+
Write-Host ""
156+
Write-Host "Invalid choice" -ForegroundColor Red
157+
}
158+
}
159+
160+
Write-Host ""
161+
Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan
162+
Write-Host " Analysis Complete" -ForegroundColor Cyan
163+
Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan
164+
Write-Host ""
165+
166+
# Offer to save analysis to file
167+
$saveAnalysis = Read-Host "Save analysis to file? (Y/N)"
168+
if ($saveAnalysis -eq "Y" -or $saveAnalysis -eq "y") {
169+
$outputFile = "benchmark_analysis_$(Get-Date -Format 'yyyy-MM-dd_HH-mm-ss').txt"
170+
171+
$latest = $mdFiles | Select-Object -First 1
172+
$content = Get-Content $latest.FullName -Raw
173+
174+
$analysis = @"
175+
???????????????????????????????????????????????????????
176+
SharpCoreDB Benchmark Analysis
177+
Generated: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')
178+
???????????????????????????????????????????????????????
179+
180+
Source File: $($latest.Name)
181+
Last Modified: $($latest.LastWriteTime)
182+
183+
$content
184+
"@
185+
186+
$analysis | Out-File -FilePath $outputFile -Encoding UTF8
187+
Write-Host ""
188+
Write-Host "? Analysis saved to: $outputFile" -ForegroundColor Green
189+
Write-Host ""
190+
}
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# ?? Benchmark Instructies
2+
3+
## ? Stap-voor-stap Guide
4+
5+
### 1?? Run Benchmarks (HANDMATIG)
6+
7+
```powershell
8+
cd SharpCoreDB.Benchmarks
9+
dotnet run -c Release
10+
```
11+
12+
**In het menu:**
13+
- Kies `1` voor **PageBasedStorageBenchmark** (Baseline vs Optimized)
14+
- Kies `2` voor **StorageEngineComparisonBenchmark** (vs SQLite & LiteDB)
15+
16+
**Wacht tot voltooid** (kan 5-15 minuten duren)
17+
18+
---
19+
20+
### 2?? Analyseer Resultaten
21+
22+
**Optie A: PowerShell Script** (AANBEVOLEN)
23+
```powershell
24+
.\AnalyzeResults.ps1
25+
```
26+
27+
Dit script:
28+
- ? Vindt automatisch de meest recente resultaten
29+
- ? Toont formatted tabel
30+
- ? Checkt voor issues
31+
- ? Biedt aan om HTML report te openen
32+
- ? Kan analyse opslaan naar .txt file
33+
34+
**Optie B: Handmatig**
35+
```powershell
36+
# Open results folder
37+
explorer BenchmarkDotNet.Artifacts\results
38+
39+
# Bekijk markdown files
40+
code BenchmarkDotNet.Artifacts\results\*-report-github.md
41+
42+
# Open HTML report (interactief)
43+
start BenchmarkDotNet.Artifacts\results\*.html
44+
```
45+
46+
---
47+
48+
### 3?? Deel Resultaten
49+
50+
**Voor analyse door AI:**
51+
```powershell
52+
# Run analyse script en save to file
53+
.\AnalyzeResults.ps1
54+
> Kies optie 1
55+
> Save analysis? Y
56+
57+
# Upload de .txt file
58+
```
59+
60+
**OF gewoon de markdown file uploaden:**
61+
```
62+
BenchmarkDotNet.Artifacts\results\SharpCoreDB.Benchmarks.PageBasedStorageBenchmark-report-github.md
63+
```
64+
65+
---
66+
67+
## ?? Output Files
68+
69+
Na het draaien van benchmarks vind je:
70+
71+
```
72+
BenchmarkDotNet.Artifacts\results\
73+
??? *-report-github.md # ? Markdown tabel (best voor Git/issues)
74+
??? *-report.html # ? Interactieve HTML (grafieken!)
75+
??? *-report.csv # ? Excel-compatible
76+
??? *-report-full.json # ? Volledige data
77+
??? *-measurements.csv # ? Ruwe metingen
78+
```
79+
80+
---
81+
82+
## ?? Verwachte Resultaten
83+
84+
### PageBasedStorageBenchmark (10K records)
85+
86+
| Operatie | Baseline | Optimized | Target Speedup | Doel |
87+
|----------|----------|-----------|----------------|------|
88+
| UPDATE 5K | ~600-800ms | ~120-180ms | **3-5x** | ? |
89+
| SELECT Scan | ~150-200ms | ~20-40ms | **5-10x** | ? |
90+
| DELETE 2K | ~400-500ms | ~80-120ms | **3-5x** | ? |
91+
| Mixed 5K | ~1200-1500ms | ~250-400ms | **3-4x** | ? |
92+
93+
### StorageEngineComparisonBenchmark (10K records)
94+
95+
| Operatie | SQLite (target) | LiteDB | PAGE_BASED | AppendOnly |
96+
|----------|-----------------|--------|------------|------------|
97+
| INSERT 10K | ~40-60ms ?? | ~120-180ms | ~200-300ms | ~500-700ms |
98+
| UPDATE 5K | ~80-120ms ?? | ~180-250ms | ~120-180ms ? | ~400-600ms |
99+
| SELECT (cached) | ~30-50ms | ~80-120ms | **~4ms** ?? | ~100-150ms |
100+
| Mixed OLTP | ~180ms ?? | ~450ms | ~250-400ms ? | ~1000ms+ |
101+
102+
**Key Insights:**
103+
- ? PAGE_BASED **10x sneller** bij cached SELECT dan SQLite
104+
- ? PAGE_BASED **bijna even snel** als SQLite bij UPDATE
105+
- ?? SQLite **6x sneller** bij raw INSERT (maar geen encryption)
106+
107+
---
108+
109+
## ?? Troubleshooting
110+
111+
### "NA" in resultaten
112+
```powershell
113+
# Benchmark is gefaald, check log:
114+
Get-Content BenchmarkDotNet.Artifacts\*.log -Tail 50
115+
```
116+
117+
### Benchmarks lopen vast
118+
- ? Gebruik ALLEEN handmatige run (niet via script)
119+
- ? Wacht geduldig (10K records = 5-15 min)
120+
- ? Check CPU usage (moet >80% zijn tijdens run)
121+
122+
### Geen resultaten gevonden
123+
```powershell
124+
# Check of results folder bestaat:
125+
Test-Path BenchmarkDotNet.Artifacts\results
126+
127+
# Als niet, run benchmarks eerst!
128+
```
129+
130+
---
131+
132+
## ?? Configuratie
133+
134+
### RecordCount aanpassen
135+
136+
**PageBasedStorageBenchmark.cs:**
137+
```csharp
138+
private const int RecordCount = 10_000; // Verander naar 1_000 voor snelle test
139+
```
140+
141+
**StorageEngineComparisonBenchmark.cs:**
142+
```csharp
143+
private const int RecordCount = 10_000; // Verander naar 1_000 voor snelle test
144+
```
145+
146+
### Warmup/Iterations aanpassen
147+
148+
**Program.cs:**
149+
```csharp
150+
var job = Job.InProcess
151+
.WithWarmupCount(1) // 0 = skip warmup (sneller maar minder accuraat)
152+
.WithIterationCount(3) // 1 = 1 run (snelste)
153+
.WithLaunchCount(1);
154+
```
155+
156+
---
157+
158+
## ? Checklist voor Succesvolle Run
159+
160+
- [ ] Build in Release mode: `dotnet build -c Release`
161+
- [ ] Start benchmark app: `dotnet run -c Release`
162+
- [ ] Kies optie 1 of 2
163+
- [ ] Wacht tot "Benchmark Complete!" verschijnt
164+
- [ ] Run `.\AnalyzeResults.ps1`
165+
- [ ] Save analysis to file
166+
- [ ] Upload analysis.txt voor review
167+
168+
---
169+
170+
## ?? Hulp Nodig?
171+
172+
**Check logs:**
173+
```powershell
174+
# Laatste benchmark log
175+
Get-ChildItem BenchmarkDotNet.Artifacts\*.log |
176+
Sort-Object LastWriteTime -Descending |
177+
Select-Object -First 1 |
178+
Get-Content -Tail 100
179+
```
180+
181+
**Clean resultaten:**
182+
```powershell
183+
# Verwijder oude results voor fresh start
184+
Remove-Item -Path BenchmarkDotNet.Artifacts -Recurse -Force
185+
```
186+
187+
---
188+
189+
**Ready to benchmark!** ??

0 commit comments

Comments
 (0)