Skip to content

Commit 47bba8e

Browse files
committed
docs: Add PERFORMANCE.md and update README
1 parent af10c30 commit 47bba8e

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

PERFORMANCE.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Performance Guidelines for SimpleDataGrid
2+
3+
This document outlines the performance characteristics and best practices for using `SimpleDataGrid` effectively, especially with large datasets.
4+
5+
## Time Complexity of Operations
6+
7+
| Operation | Time Complexity (Worst Case) |
8+
| :--------------- | :--------------------------- |
9+
| `SetSource` | O(N) |
10+
| `AddFilter` | O(N) |
11+
| `SetFilter` | O(N) |
12+
| `RemoveFilter` | O(N) |
13+
| `ClearFilters` | O(N) |
14+
| `SetSearch` | O(N * M) |
15+
| `SetSearchAll` | O(N * M) |
16+
| `ClearSearch` | O(N) |
17+
| `SetSort` | O(N log N) |
18+
| `ClearSort` | O(N) |
19+
| `NextPage` | O(P) |
20+
| `PreviousPage` | O(P) |
21+
| `GoToPage` | O(P) |
22+
| `SetPageSize` | O(P) |
23+
24+
* **N**: Total number of items in the source collection.
25+
* **M**: Number of search selectors (properties being searched).
26+
* **P**: Page size (number of items per page).
27+
28+
## Guidance for Datasets
29+
30+
### Small Datasets (< 1,000 items)
31+
32+
For small datasets, `SimpleDataGrid` performs exceptionally well. All operations are fast, and users will experience a highly responsive UI. There are generally no specific performance optimizations needed for this scale.
33+
34+
### Medium Datasets (1,000 - 100,000 items)
35+
36+
`SimpleDataGrid` is designed to handle medium-sized datasets efficiently. However, some considerations can further improve performance:
37+
38+
* **Filtering and Searching:** While `O(N)` and `O(N*M)` operations are acceptable, frequent changes to filters or search terms can lead to noticeable delays. Utilize the `debounceMilliseconds` parameter in `SetSearch` to prevent excessive re-filtering on every keystroke.
39+
* **Page Size:** A larger page size reduces the number of page changes but increases the rendering time for each page. A smaller page size makes page transitions faster but requires more frequent paging. Experiment with page sizes (e.g., 25, 50, 100) to find the optimal balance for your application and user experience.
40+
* **Complex Filters/Selectors:** Avoid overly complex filter predicates or search selectors that involve heavy computations, as these will directly impact the `O(N)` or `O(N*M)` operations.
41+
42+
### Large Datasets (> 100,000 items)
43+
44+
For very large datasets, `SimpleDataGrid` might experience performance limitations due to its in-memory processing nature. Consider the following alternatives and strategies:
45+
46+
* **Server-Side Pagination/Filtering/Sorting:** For truly massive datasets, it is highly recommended to implement server-side processing. This means that filtering, sorting, and pagination operations are performed by a backend service (e.g., a database) and only the data for the current page is sent to the client. `SimpleDataGrid` can still be used as the UI component, but its `PagedCollection` would need to be adapted to fetch data from the server.
47+
* **Data Virtualization:** WPF's built-in UI virtualization for `DataGrid` can help with rendering large numbers of rows by only rendering the visible rows. Ensure your `DataGrid` is configured to use UI virtualization.
48+
* **Optimized Data Structures:** If in-memory processing is unavoidable, consider using more optimized data structures for your source collection if possible, though `IReadOnlyList<T>` is generally efficient.
49+
50+
## Memory Usage Characteristics
51+
52+
`SimpleDataGrid` keeps the entire filtered and sorted dataset in memory (`_filtered` collection). For very large datasets, this can lead to significant memory consumption. If memory becomes a concern, server-side processing or on-demand loading of data chunks should be considered.
53+
54+
## Benchmarks (Future Work)
55+
56+
Specific benchmarks for various dataset sizes and operation types will be added in future updates to provide more concrete performance metrics.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ To run the example project:
152152
dotnet run --project SimpleDataGrid.Example
153153
```
154154

155+
## Performance
156+
157+
For detailed information on performance characteristics and best practices, refer to the [PERFORMANCE.md](PERFORMANCE.md) document.
158+
155159
## License
156160

157161
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)