Skip to content

Commit c6cd6bf

Browse files
committed
Show some benchmarking in the README, etc
1 parent 7aefdbc commit c6cd6bf

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -146,36 +146,36 @@ dotnet run -c=Release --project=Benchmarking
146146
```
147147

148148
### Quick performance comparison between relevant collection types
149-
| Task | List | DictionaryList | Dictionary | SortedDictionary |
150-
|-------------------------------------|----------|----------------|---------------|------------------|
151-
| Append Many Items (speed) | 👍 | 👌 | 👎👎 | 👎👎👎 |
152-
| Append Many Items (memory) | 👍 | 👌 | 👎👎 | 👎 |
153-
| Full Iteration (speed) | 👍 | 👎 | 👌 | 👎👎 |
154-
| Full Iteration (memory) | 👍 (0) | 👌 | 👍 (0) | 👌 |
155-
| Read Many Items (speed) | 👍 | 👌 | 👎 | 👎👎 |
156-
| Read Many Items (memory) | 👍 (0) | 👍 (0) | 👍 (0) | 👍 (0) |
157-
| Remove Many Items In-place (speed) | 👎👎👎 | 👌 | 👍 | 👌 |
158-
| Remove Many Items In-place (memory) | 👍 (0) | 👌 | 👍 (0) | 👌 |
159-
| Remove Many Items w/ LINQ (speed) | 👍 | 👌 | 👎👎 | 👎👎 |
160-
| Remove Many Items w/ LINQ (memory) | 👍 | 👌 | 👎 | 👎👎 |
161-
| Add Items During `foreach` ||| ❌ if new hash ||
162-
| Emit Key/Index During `foreach` | 🤷 ([1]) | ✔️ | ✔️ | ✔️ |
163-
| Replace Items During `foreach` | 🤷 ([1]) | ✔️ | ✔️ | ❌ if key exists |
164-
| Remove Items During `foreach` || ✔️ | ✔️ ||
149+
A benchmark was run with version `0.1.2` of this library. Its detailed results can be found in `BENCHMARK.md`.
150+
151+
But still, here is a table outlining the performances when `N = 100000`:
152+
153+
| Task | List | DictionaryList | Dictionary | SortedDictionary |
154+
|-------------------------------------|-------------|----------------|------------|------------------|
155+
| Append Many Items (speed) | 155 ms ⭐ | 317 ms 👌 | 1073 ms | 10507 ms |
156+
| Append Many Items (memory) | 1048976 B ⭐ | 2097536 B 👌 | 6037640 B | 4800112 B |
157+
| Full Iteration (speed) | 50 ms ⭐ | 176 ms 👌 | 162 ms | 587 ms |
158+
| Full Iteration (memory) | 0 B | 48 B | 0 B | 312 B |
159+
| Read Many Items (speed) | 17 ms ⭐ | 65 ms 👌 | 147 ms | 1322 ms |
160+
| Read Many Items (memory) | 0 B | 0 B | 0 B | 0 B |
161+
| Remove Many Items In-place (speed) | 557307 ms | 789 ms 👌 | 316 ms ⭐ | 810 ms |
162+
| Remove Many Items In-place (memory) | 0 B | 48 B | 0 B | 312 B |
163+
| Remove Many Items w/ LINQ (speed) | 104 ms ⭐ | 793 ms 👌 | 885 ms | 1693 ms |
164+
| Remove Many Items w/ LINQ (memory) | 198072 B ⭐ | 529280 B 👌 | 673168 B | 1473296 B |
165+
| Add Items During `foreach` ||| ❌ new key ||
166+
| Emit Key/Index During `foreach` | 🤷 ([1]) | ✔️ | ✔️ | ✔️ |
167+
| Replace Items During `foreach` | 🤷 ([1]) | ✔️ | ✔️ | ❌ if key exists |
168+
| Remove Items During `foreach` || ✔️ | ✔️ ||
165169

166170
You may see that `DictionaryList<T>` is an all-rounded, midway solution between a `List<T>` and a `Dictionary<TKey,TValue>`.
167171

168172
As part of the benchmark, you may also see that `SortedDictionary<TKey,TValue>` is generally a bad type to use compared to other similar types.
169173

170174
The following collection types are excluded from the benchmarking:
171-
- `OrderedDictionary`: ambiguity between intended `<int,T>` usage and `this[int]` syntax
175+
- `HashSet<T>`: too similar to `Dictionary<T, void>`, probably has similar performance
176+
- `OrderedDictionary`: ambiguity between intended `<int, T>` usage and `this[int]` syntax
172177
- `LinkedList<T>`: unfair/impossible comparison due to lack of index access
173-
- `SortedList<int,T>`: too similar to `SortedDictionary<int,T>`, probably has similar performance
174-
175-
### Sample benchmarking results
176-
The benchmark is run with version `0.1.2` of this library.
177-
178-
For details, please see `BENCHMARK.md`.
178+
- `SortedList<int,T>`: too similar to `SortedDictionary<int, T>`, probably has similar performance
179179

180180
## Testing
181181
This package uses NUnit for testing.
@@ -187,7 +187,7 @@ dotnet test
187187
```
188188

189189
## Appendix
190-
[1] Technically, this can be done with Enumerable LINQ's Index method, but using LINQ with `foreach` is perhaps an antipattern.
190+
[1] Technically, this can be done with Enumerable LINQ's `Index` method, but using LINQ with `foreach` is perhaps an antipattern.
191191

192192
[nuget-url]: https://www.nuget.org/packages/Vectorial1024.DictionaryList/
193193
[nuget-stats-url]: https://www.nuget.org/stats/packages/Vectorial1024.DictionaryList?groupby=Version

0 commit comments

Comments
 (0)