validation and profiles

This commit is contained in:
Miha Kralj
2026-02-26 22:02:52 -08:00
parent 9ab37c1200
commit 8a1ba95173
317 changed files with 18704 additions and 622 deletions
+13
View File
@@ -90,6 +90,19 @@ double typical = bar.HLC3;
## Performance Profile
### Operation Count (Streaming Mode)
TBar is a 48-byte struct (DateTime + 5 doubles). Field access and construction are stack/register operations.
| Operation | Count | Cost (cycles) | Subtotal |
| :--- | :---: | :---: | :---: |
| Struct construction (6 fields) | 6 | 1 cy | ~6 cy |
| Field read (O/H/L/C/V) | 1 | 0 cy | ~0 cy |
| TypicalPrice = (H+L+C)/3 | 1 | 2 cy | ~2 cy |
| **Total** | **O(1)** | — | **~8 cy** |
48-byte struct spans 3 cache lines but is typically stack-allocated. JIT may promote to registers for short-lived locals. No heap allocation.
* **Memory**: 48 bytes per instance.
* **Allocation**: 0 bytes (Stack allocated).
* **Access**: Direct field access (no property overhead).
+13
View File
@@ -99,6 +99,19 @@ bars.Add(updatedBar, isNew: false); // Updates the last bar in place
## Performance Profile
### Operation Count (Streaming Mode)
TBarSeries stores OHLCV as separate List<T> fields (SoA layout) for cache-friendly sequential access.
| Operation | Count | Cost (cycles) | Subtotal |
| :--- | :---: | :---: | :---: |
| Add new TBar (5 List.Add calls) | 5 | 3 cy | ~15 cy |
| Access span for SIMD | 1 | 2 cy | ~2 cy |
| Pub event fire | 1 | 5 cy | ~5 cy |
| **Total per bar** | **O(1)** | — | **~22 cy** |
SoA layout enables SIMD processing: each field array is contiguous in memory. CollectionsMarshal.AsSpan avoids copying.
* **Memory Layout**: SoA (Structure of Arrays).
* **Component Access**: Zero-copy `TSeries` views.
* **Iteration**: Cache-friendly for single-component analysis.
+14
View File
@@ -90,6 +90,20 @@ series.Pub += (item) => Console.WriteLine($"New value: {item}");
## Performance Profile
### Operation Count (Streaming Mode)
TSeries stores timestamps and values as parallel List<long> + List<double> (SoA). Pub/Sub event-driven streaming.
| Operation | Count | Cost (cycles) | Subtotal |
| :--- | :---: | :---: | :---: |
| Add TValue (2 List.Add calls) | 2 | 3 cy | ~6 cy |
| isNew check + rollback | 1 | 2 cy | ~2 cy |
| Pub event fire | 1 | 5 cy | ~5 cy |
| AsSpan (CollectionsMarshal) | 1 | 2 cy | ~2 cy |
| **Total per bar** | **O(1)** | — | **~15 cy** |
The Pub/Sub dispatch dominates practical throughput when multiple subscribers are chained. Solo update without subscribers: ~8 cy.
* **Memory Layout**: SoA (Structure of Arrays).
* **Access Speed**: O(1) for random access.
* **Iteration**: Cache-friendly linear scan.
+13
View File
@@ -76,6 +76,19 @@ Console.WriteLine(tv); // Output: "[2024-01-01 12:00:00, 42.00]"
## Performance Profile
### Operation Count (Streaming Mode)
TValue is a 16-byte struct (DateTime + double). Construction and field access are register operations.
| Operation | Count | Cost (cycles) | Subtotal |
| :--- | :---: | :---: | :---: |
| Struct construction (2 fields) | 2 | 1 cy | ~2 cy |
| Field read (Tm or Val) | 1 | 0 cy | ~0 cy |
| IsNaN check on Val | 1 | 1 cy | ~1 cy |
| **Total** | **O(1)** | — | **~3 cy** |
16-byte struct fits in a single XMM register. Zero heap allocation. All operations are register-bound when JIT-promoted.
* **Memory**: 16 bytes per instance.
* **Allocation**: 0 bytes (Stack allocated).
* **Copying**: Cheap (fits in two 64-bit registers).