Skip to content

Commit ebc2ecc

Browse files
committed
Cleanup
1 parent 37bb428 commit ebc2ecc

4 files changed

Lines changed: 71 additions & 57 deletions

File tree

Directory.Packages.props

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
<CentralPackageVersionOverrideEnabled>true</CentralPackageVersionOverrideEnabled>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageVersion Include="Friflo.Engine.ECS" Version="3.4.2" />
7+
<PackageVersion Include="Friflo.Engine.ECS" Version="3.6.0" />
88
<PackageVersion Include="DefaultEcs" Version="0.17.2" />
9-
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
9+
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.300" />
1010
</ItemGroup>
1111
<ItemGroup>
1212
<PackageVersion Include="MonoGame.Framework.DesktopGL" Version="3.8.4.1" />
1313
</ItemGroup>
1414
<ItemGroup>
1515
<PackageVersion Include="AutoFixture.Xunit2" Version="4.18.1" />
1616
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
17-
<PackageVersion Include="FluentAssertions" Version="8.8.0" />
18-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
17+
<PackageVersion Include="FluentAssertions" Version="8.10.0" />
18+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.8.1" />
1919
<PackageVersion Include="Moq" Version="4.20.72" />
2020
<PackageVersion Include="xunit" Version="2.9.3" />
21-
<PackageVersion Include="JunitXml.TestLogger" Version="7.1.0" />
21+
<PackageVersion Include="JunitXml.TestLogger" Version="8.0.0" />
2222
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
23-
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
24-
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
23+
<PackageVersion Include="coverlet.msbuild" Version="10.0.1" />
24+
<PackageVersion Include="coverlet.collector" Version="10.0.1" />
2525
</ItemGroup>
2626
</Project>

src/Hexecs.Benchmarks.City/BenchmarkCounter.cs

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ internal sealed class BenchmarkCounter
2828
private readonly Vector2 _textPos = new(10, 10);
2929
private readonly Vector2 _shadowPos = new(11, 11);
3030

31-
public BenchmarkCounter(Func<int> countResolver, ContentManager contentManager, GraphicsDevice graphicsDevice)
31+
public BenchmarkCounter(Func<int> countResolver,
32+
ContentManager contentManager,
33+
GraphicsDevice graphicsDevice)
3234
{
3335
_countResolver = countResolver;
3436
_fpsHistory = new int[60];
@@ -54,36 +56,39 @@ public void Update(GameTime gameTime)
5456
_frameTime = gameTime.ElapsedGameTime.TotalMilliseconds;
5557
_fpsTimer += elapsedSeconds;
5658

57-
if (_fpsTimer >= 1.0)
59+
if (_fpsTimer < 1.0)
5860
{
59-
_fps = _frameCount;
61+
return;
62+
}
6063

61-
_historySum -= _fpsHistory[_historyIndex];
62-
_fpsHistory[_historyIndex] = _fps;
63-
_historySum += _fps;
64+
_fps = _frameCount;
6465

65-
_historyIndex = (_historyIndex + 1) % 60;
66-
if (_historyIndex == 0) _historyFull = true;
66+
ref var historySum = ref _fpsHistory[_historyIndex];
67+
_historySum -= historySum;
68+
historySum = _fps;
69+
_historySum += _fps;
6770

68-
var historyCount = _historyFull ? 60 : _historyIndex;
69-
_avgFps = (double)_historySum / historyCount;
71+
_historyIndex = (_historyIndex + 1) % 60;
72+
if (_historyIndex == 0) _historyFull = true;
7073

71-
var alloc = GC.GetTotalMemory(false) / 1024.0 / 1024.0;
72-
var count = _countResolver();
74+
var historyCount = _historyFull ? 60 : _historyIndex;
75+
_avgFps = (double)_historySum / historyCount;
7376

74-
// Очищаем буфер и записываем новые данные без создания строк
75-
var culture = CultureInfo.InvariantCulture;
77+
var alloc = GC.GetTotalMemory(false) / 1024.0 / 1024.0;
78+
var count = _countResolver();
7679

77-
_stringBuilder.Clear();
78-
_stringBuilder
79-
.Append($"{_fps} FPS")
80-
.Append(culture, $" | Avg:{_avgFps:F1} fps")
81-
.Append(culture, $" | Entities:{count:N0}")
82-
.Append(culture, $" | Frame time:{_frameTime:F1}ms")
83-
.Append(culture, $" | Alloc:{alloc:F3}mb");
80+
// Очищаем буфер и записываем новые данные без создания строк
81+
var culture = CultureInfo.InvariantCulture;
8482

85-
_frameCount = 0;
86-
_fpsTimer = 0;
87-
}
83+
_stringBuilder.Clear();
84+
_stringBuilder
85+
.Append($"{_fps} FPS")
86+
.Append(culture, $" | Avg:{_avgFps:F1} fps")
87+
.Append(culture, $" | Entities:{count:N0}")
88+
.Append(culture, $" | Frame time:{_frameTime:F1}ms")
89+
.Append(culture, $" | Alloc:{alloc:F3}mb");
90+
91+
_frameCount = 0;
92+
_fpsTimer = 0;
8893
}
8994
}

src/Hexecs.Benchmarks.Noise/BenchmarkCounter.cs

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ internal sealed class BenchmarkCounter
2828
private readonly Vector2 _textPos = new(10, 10);
2929
private readonly Vector2 _shadowPos = new(11, 11);
3030

31-
public BenchmarkCounter(Func<int> countResolver, ContentManager contentManager, GraphicsDevice graphicsDevice)
31+
public BenchmarkCounter(
32+
Func<int> countResolver,
33+
ContentManager contentManager,
34+
GraphicsDevice graphicsDevice)
3235
{
3336
_countResolver = countResolver;
3437
_fpsHistory = new int[60];
@@ -50,40 +53,45 @@ public void Draw(GameTime gameTime)
5053

5154
public void Update(GameTime gameTime)
5255
{
53-
var elapsedSeconds = gameTime.ElapsedGameTime.TotalSeconds;
54-
_frameTime = gameTime.ElapsedGameTime.TotalMilliseconds;
56+
var elapsedGameTime = gameTime.ElapsedGameTime;
57+
var elapsedSeconds = elapsedGameTime.TotalSeconds;
58+
59+
_frameTime = elapsedGameTime.TotalMilliseconds;
5560
_fpsTimer += elapsedSeconds;
5661

57-
if (_fpsTimer >= 1.0)
62+
if (_fpsTimer < 1.0)
5863
{
59-
_fps = _frameCount;
64+
return;
65+
}
6066

61-
_historySum -= _fpsHistory[_historyIndex];
62-
_fpsHistory[_historyIndex] = _fps;
63-
_historySum += _fps;
67+
_fps = _frameCount;
6468

65-
_historyIndex = (_historyIndex + 1) % 60;
66-
if (_historyIndex == 0) _historyFull = true;
69+
ref var historySum = ref _fpsHistory[_historyIndex];
70+
_historySum -= historySum;
71+
historySum = _fps;
72+
_historySum += _fps;
6773

68-
var historyCount = _historyFull ? 60 : _historyIndex;
69-
_avgFps = (double)_historySum / historyCount;
74+
_historyIndex = (_historyIndex + 1) % 60;
75+
if (_historyIndex == 0) _historyFull = true;
7076

71-
var alloc = GC.GetTotalMemory(false) / 1024.0 / 1024.0;
72-
var count = _countResolver();
77+
var historyCount = _historyFull ? 60 : _historyIndex;
78+
_avgFps = (double)_historySum / historyCount;
7379

74-
// Очищаем буфер и записываем новые данные без создания строк
75-
var culture = CultureInfo.InvariantCulture;
80+
var alloc = GC.GetTotalMemory(false) / 1024.0 / 1024.0;
81+
var count = _countResolver();
7682

77-
_stringBuilder.Clear();
78-
_stringBuilder
79-
.Append($"{_fps} FPS")
80-
.Append(culture, $" | Avg:{_avgFps:F1} fps")
81-
.Append(culture, $" | Entities:{count:N0}")
82-
.Append(culture, $" | Frame time:{_frameTime:F1}ms")
83-
.Append(culture, $" | Alloc:{alloc:F3}mb");
83+
// Очищаем буфер и записываем новые данные без создания строк
84+
var culture = CultureInfo.InvariantCulture;
8485

85-
_frameCount = 0;
86-
_fpsTimer = 0;
87-
}
86+
_stringBuilder.Clear();
87+
_stringBuilder
88+
.Append($"{_fps} FPS")
89+
.Append(culture, $" | Avg:{_avgFps:F1} fps")
90+
.Append(culture, $" | Entities:{count:N0}")
91+
.Append(culture, $" | Frame time:{_frameTime:F1}ms")
92+
.Append(culture, $" | Alloc:{alloc:F3}mb");
93+
94+
_frameCount = 0;
95+
_fpsTimer = 0;
8896
}
8997
}

src/Hexecs/Actors/Systems/UpdateSystem1.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace Hexecs.Actors.Systems;
55

6+
[SuppressMessage("ReSharper", "InvertIf")]
67
public abstract class UpdateSystem<T1> : UpdateSystem, IParallelJob
78
where T1 : struct, IActorComponent
89
{

0 commit comments

Comments
 (0)