Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collections update to 4 0 0 #67

Merged

Conversation

kaltinril
Copy link
Contributor

  1. Copied Collections.md and object-pooling.md out of Archive
  2. Re-worked many of the code examples
  3. Added code examples for every collection and extension
  4. ObjectPool and Pool were somehow intertwined in the example code previously, that is now separated and fixed.
  5. Benchmarked the C# .NET standard library functions for:
    1. ConcurrentBag vs Bag
      1. MonoGame.Extended's Bag was insanely faster, which makes sense because Microsoft's ConcurrentBag is thread safe.
      2. Add was 100 times slower than MonoGame's (92ms vs 1161ms)
      3. Remove was 10 times slower than MonoGame's (76ms vs 900ms)
    2. KeyedCollection
      1. Adding was close, but Microsoft's implementation had horrible Remove performance (2ms vs 646ms)

Since it was such a big change, I anticipate typo/spelling/formatting/and code issues. Please provide input and I'll work on the fixes.

I'll work on the Samples and push those up in that Repo.

BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4037/23H2/2023Update/SunValley3)
AMD Ryzen 7 5800X, 1 CPU, 16 logical and 8 physical cores
.NET SDK 8.0.304
  [Host]     : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2
  Job-FQVXUQ : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2

InvocationCount=1  UnrollFactor=1

| Method                         | Mean        | Error     | StdDev    |
|------------------------------- |------------:|----------:|----------:|
| AddToConcurrentBag             | 1,161.49 ms | 23.163 ms | 23.786 ms |
| AddToMonoGameBag               |    92.00 ms |  1.258 ms |  1.176 ms |
| RemoveFromConcurrentBag        |   901.99 ms |  5.320 ms |  4.154 ms |
| RemoveFromMonogameBagBestCase  |    69.80 ms |  0.409 ms |  0.383 ms |
| RemoveFromMonogameBagWorseCase |    76.05 ms |  0.254 ms |  0.199 ms |
BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4037/23H2/2023Update/SunValley3)
AMD Ryzen 7 5800X, 1 CPU, 16 logical and 8 physical cores
.NET SDK 8.0.304
  [Host]     : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2 [AttachedDebugger]
  Job-FPKGHY : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2

InvocationCount=1  UnrollFactor=1

| Method                            | Mean       | Error     | StdDev    | Median      |
|---------------------------------- |-----------:|----------:|----------:|------------:|
| AddToSystemKeyedCollection        |   2.086 ms | 0.1203 ms | 0.3527 ms |   2.0842 ms |
| AddToMonoGameKeyedCollection      |   1.019 ms | 0.0472 ms | 0.1354 ms |   0.9855 ms |
| RemoveFromSystemKeyedCollection   | 646.276 ms | 5.2726 ms | 4.9320 ms | 643.3841 ms |
| RemoveFromMonoGameKeyedCollection |   1.036 ms | 0.0459 ms | 0.1232 ms |   0.9987 ms |

@kaltinril
Copy link
Contributor Author

I've created the sample code that prints (to debug) to demonstrate each collection, pool, and extension method.

craftworkgames/MonoGame.Extended-samples#15

Copy link
Contributor

@AristurtleDev AristurtleDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of changes requested

docs/features/collections/collections.md Show resolved Hide resolved
docs/features/object-pooling/object-pooling.md Outdated Show resolved Hide resolved
docs/features/object-pooling/object-pooling.md Outdated Show resolved Hide resolved
@AristurtleDev AristurtleDev merged commit a289d53 into craftworkgames:develop Sep 23, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants