- Built executables in
build\folder - Windows Command Prompt, PowerShell, or VSCode terminal
cd C:\path\to\your\project
build_simple.batExpected output:
[1/2] Building processor...
[SUCCESS] orderbook_processor.exe built successfully
[2/2] Building generator...
[SUCCESS] stream_generator.exe built successfully
Build complete!
build\stream_generator.exe build\input1.bintype build\input1.bin | build\orderbook_processor.exe 5Expected output:
1, SB0, [(..., ...)], []
2, SB0, [(..., ...), (..., ...)], []
3, SB0, [(..., ...), (..., ...)], []
4, SB0, [(..., ...), (..., ...)], [(..., ...)]
5, SB0, [(..., ...), (..., ...)], [(..., ...)]
6, SB0, [(..., ...), (..., ...)], []
7, SB0, [(..., ...), (..., ...)], []
8, SB0, [(..., ...), (..., ...)], []
9, SB0, [(..., ...)], []
PowerShell requires different syntax for piping binary data:
# Navigate to project
cd C:\path\to\your\project
# Build
.\build_simple.bat
# Generate test file
.\build\stream_generator.exe build\input1.
# Run processor (PowerShell method)
Get-Content build\input1.bin -Raw -Encoding Byte | .\build\orderbook_processor.exe 5
# Or save output to file
Get-Content build\input1.bin -Raw -Encoding Byte | .\build\orderbook_processor.exe 5 > output.log
# Compare with expected
Compare-Object (Get-Content output1.log) (Get-Content output.log)# Test depth = 3
Get-Content build\input1.bin -Raw -Encoding Byte | .\build\orderbook_processor.exe 3
# Test depth = 10
Get-Content build\input1.bin -Raw -Encoding Byte | .\build\orderbook_processor.exe 10
# Test depth = 20
Get-Content build\input1.bin -Raw -Encoding Byte | .\build\orderbook_processor.exe 20Create test.bat in your project folder:
@echo off
echo ============================================
echo Order Book Processor - Test Suite
echo ============================================
REM Check if build directory exists
if not exist build (
echo ERROR: Build directory not found!
echo Please run build_simple.bat first
exit /b 1
)
REM Check if executables exist
if not exist build\orderbook_processor.exe (
echo ERROR: orderbook_processor.exe not found!
echo Please run build_simple.bat first
exit /b 1
)
if not exist build\stream_generator.exe (
echo ERROR: stream_generator.exe not found!
echo Please run build_simple.bat first
exit /b 1
)
echo.
echo [TEST 1] Generating small test file...
build\stream_generator.exe build\input1.bin
if %ERRORLEVEL% NEQ 0 (
echo FAILED: Could not generate test file
exit /b 1
)
echo SUCCESS: Test file generated
echo.
echo [TEST 2] Running processor with depth=5...
type build\input1.bin | build\orderbook_processor.exe 5 > build\actual_output.log
if %ERRORLEVEL% NEQ 0 (
echo FAILED: Processor returned error
exit /b 1
)
echo SUCCESS: Processor completed
echo.
echo [TEST 3] Validating output...
fc /b output1.log build\actual_output.log > nul
if %ERRORLEVEL% EQU 0 (
echo SUCCESS: Output matches expected!
) else (
echo WARNING: Output differs from expected
echo Expected output:
type output1.log
echo.
echo Actual output:
type build\actual_output.log
)
echo.
echo [TEST 4] Generating 1MB test file...
build\stream_generator.exe build\large_1mb.bin 1
echo SUCCESS: 1MB file generated
echo.
echo [TEST 5] Processing 1MB file (first 10 lines)...
type build\large_1mb.bin | build\orderbook_processor.exe 5 | more +0 | findstr /n "^" | findstr "^[1-9]:" | findstr "^[1-9]:"
echo SUCCESS: 1MB file processed
echo.
echo [TEST 6] Testing different depth levels...
for %%d in (3 5 10 20) do (
echo Testing depth=%%d...
type build\input1.bin | build\orderbook_processor.exe %%d > nul
if !ERRORLEVEL! EQU 0 (
echo SUCCESS: depth=%%d
) else (
echo FAILED: depth=%%d
)
)
echo.
echo ============================================
echo All tests completed!
echo ============================================
pauseRun it:
test.batCreate benchmark.bat:
@echo off
echo ============================================
echo Performance Benchmark
echo ============================================
if not exist build\large_1mb.bin (
echo Generating 1MB test file...
build\stream_generator.exe build\large_1mb.bin 1
)
if not exist build\large_2mb.bin (
echo Generating 2MB test file...
build\stream_generator.exe build\large_2mb.bin 2
)
echo.
echo Benchmarking 1MB file...
echo Start time: %TIME%
type build\large_1mb.bin | build\orderbook_processor.exe 5 > nul
echo End time: %TIME%
echo.
echo Benchmarking 2MB file...
echo Start time: %TIME%
type build\large_2mb.bin | build\orderbook_processor.exe 10 > nul
echo End time: %TIME%
echo.
echo Done!
pause# benchmark.ps1
Write-Host "============================================" -ForegroundColor Yellow
Write-Host "Performance Benchmark" -ForegroundColor Yellow
Write-Host "============================================" -ForegroundColor Yellow
# Generate test files if needed
if (-not (Test-Path "build\large_1mb.bin")) {
Write-Host "Generating 1MB test file..." -ForegroundColor Cyan
.\build\stream_generator.exe build\large_1mb.bin 1
}
if (-not (Test-Path "build\large_2mb.bin")) {
Write-Host "Generating 2MB test file..." -ForegroundColor Cyan
.\build\stream_generator.exe build\large_2mb.bin 2
}
# Benchmark 1MB file
Write-Host "`nBenchmarking 1MB file (depth=5)..." -ForegroundColor Cyan
$time1mb = Measure-Command {
Get-Content build\large_1mb.bin -Raw -Encoding Byte |
.\build\orderbook_processor.exe 5 | Out-Null
}
Write-Host "Time: $($time1mb.TotalMilliseconds) ms" -ForegroundColor Green
# Benchmark 2MB file
Write-Host "`nBenchmarking 2MB file (depth=10)..." -ForegroundColor Cyan
$time2mb = Measure-Command {
Get-Content build\large_2mb.bin -Raw -Encoding Byte |
.\build\orderbook_processor.exe 10 | Out-Null
}
Write-Host "Time: $($time2mb.TotalMilliseconds) ms" -ForegroundColor Green
# Calculate throughput
$size1mb = (Get-Item "build\large_1mb.bin").Length / 1MB
$size2mb = (Get-Item "build\large_2mb.bin").Length / 1MB
Write-Host "`n============================================" -ForegroundColor Yellow
Write-Host "Results:" -ForegroundColor Yellow
Write-Host " 1MB file: $($time1mb.TotalMilliseconds) ms" -ForegroundColor White
Write-Host " 2MB file: $($time2mb.TotalMilliseconds) ms" -ForegroundColor White
Write-Host " Throughput: $([math]::Round($size2mb / $time2mb.TotalSeconds, 2)) MB/s" -ForegroundColor White
Write-Host "============================================" -ForegroundColor YellowRun it:
.\benchmark.ps1REM Generate and run
build\stream_generator.exe build\input1.bin
type build\input1.bin | build\orderbook_processor.exe 5 > build\actual.log
REM Compare files (shows differences)
fc output1.log build\actual.log
REM Or use findstr to check specific patterns
findstr "318800" build\actual.log# Generate test data
.\build\stream_generator.exe build\input1.bin
# Run processor
Get-Content build\input1.bin -Raw -Encoding Byte |
.\build\orderbook_processor.exe 5 |
Out-File -Encoding ASCII build\actual.log
# Compare
$expected = Get-Content output1.log
$actual = Get-Content build\actual.log
$diff = Compare-Object $expected $actual
if ($diff -eq $null) {
Write-Host "β Output matches expected!" -ForegroundColor Green
} else {
Write-Host "β Output differs:" -ForegroundColor Red
$diff | Format-Table
}REM Generate custom size test file
build\stream_generator.exe build\custom_test.bin 5
REM Process it
type build\custom_test.bin | build\orderbook_processor.exe 10 > results.log
REM View results
type results.log | more@echo off
for %%f in (build\*.bin) do (
echo Processing %%f...
type %%f | build\orderbook_processor.exe 5 > %%f.output
)
echo All files processed!REM Process and filter for specific symbol
type build\input1.bin | build\orderbook_processor.exe 5 | findstr "SB0"
REM Count snapshots per symbol
type build\input1.bin | build\orderbook_processor.exe 5 | findstr /c:"SB0" | find /c ","REM Generate large test
build\stream_generator.exe build\test.bin 10
REM Process with different depths and save
type build\test.bin | build\orderbook_processor.exe 3 > depth3.log
type build\test.bin | build\orderbook_processor.exe 5 > depth5.log
type build\test.bin | build\orderbook_processor.exe 10 > depth10.log
REM Compare line counts
for %%f in (depth*.log) do (
echo %%f:
find /c "," %%f
)In VSCode, open terminal with Ctrl+` then:
# Build
build_simple.bat
# Test
build\stream_generator.exe build\test.bin
type build\test.bin | build\orderbook_processor.exe 5# Build
.\build_simple.bat
# Test
.\build\stream_generator.exe build\test.bin
Get-Content build\test.bin -Raw -Encoding Byte | .\build\orderbook_processor.exe 5# Build
./build_simple.bat
# Test
./build/stream_generator.exe build/test.bin
cat build/test.bin | ./build/orderbook_processor.exe 5Here's a complete workflow from start to finish:
REM 1. Navigate to project
cd C:\Users\YourName\Projects\OrderBookProcessor
REM 2. Build everything
build_simple.bat
REM 3. Create build directory (if needed)
if not exist build mkdir build
REM 4. Generate small test file
build\stream_generator.exe build\input1.bin
REM 5. Test with depth=5
type build\input1.bin | build\orderbook_processor.exe 5
REM 6. Save output
type build\input1.bin | build\orderbook_processor.exe 5 > build\output.log
REM 7. Validate
fc output1.log build\output.log
REM 8. Generate large file for performance testing
build\stream_generator.exe build\large.bin 2
REM 9. Process large file
type build\large.bin | build\orderbook_processor.exe 10 > build\large_output.log
REM 10. Check results
type build\large_output.log | more| Task | Command Prompt | PowerShell |
|---|---|---|
| Build | build_simple.bat |
.\build_simple.bat |
| Generate small test | build\stream_generator.exe build\test.bin |
.\build\stream_generator.exe build\test.bin |
| Generate 1MB file | build\stream_generator.exe build\large.bin 1 |
.\build\stream_generator.exe build\large.bin 1 |
| Run processor | type build\test.bin | build\orderbook_processor.exe 5 |
Get-Content build\test.bin -Raw -Encoding Byte | .\build\orderbook_processor.exe 5 |
| Save output | type ... | ... > output.log |
... | Out-File output.log |
| View output | type output.log |
Get-Content output.log |
| Compare files | fc file1.log file2.log |
Compare-Object (Get-Content file1.log) (Get-Content file2.log) |
| Count lines | find /c "," file.log |
(Get-Content file.log).Count |
-
Binary Data Piping:
- Command Prompt: Use
type(works for binary) - PowerShell: Use
Get-Content -Raw -Encoding Byte
- Command Prompt: Use
-
Path Separators:
- Use backslash
\for Windows paths - In VSCode terminal, forward slash
/also works
- Use backslash
-
File Extensions:
- Always use
.exeextension on Windows .batfor batch files.ps1for PowerShell scripts
- Always use
-
Execution Policy (PowerShell):
# If scripts won't run: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
REM Make sure files aren't read-only
attrib -r build\*.exeREM Check current directory
cd
REM List files
dir build\*.exe
REM Create build directory if needed
if not exist build mkdir buildREM Make sure using 'type' not 'more' or 'cat'
type build\test.bin | build\orderbook_processor.exe 5# Use -Raw and -Encoding Byte for binary data
Get-Content file.bin -Raw -Encoding Byte | .\program.exeAll the batch scripts and examples are available in the artifacts:
build_simple.bat- Simple build scripttest.bat- Complete test suitebenchmark.bat- Performance testing
Just copy them to your project directory and run!