Skip to content

Commit

Permalink
优化处理器统计,避免过渡裁剪
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed May 22, 2024
1 parent 56a0d5b commit 886914b
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 13 deletions.
4 changes: 2 additions & 2 deletions ClientTest/ClientTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NewLife.Redis" Version="5.6.2024.420-beta0005" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NewLife.Redis" Version="5.6.2024.508" />
<PackageReference Include="NewLife.UnitTest" Version="1.0.2024.102-beta0146" />
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
Expand Down
2 changes: 1 addition & 1 deletion Plugins/MySqlAgent/MySqlAgent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.XCode" Version="11.12.2024.507" />
<PackageReference Include="NewLife.XCode" Version="11.12.2024.515" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Stardust.Data/Stardust.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.XCode" Version="11.12.2024.503" />
<PackageReference Include="NewLife.XCode" Version="11.12.2024.515" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 9 additions & 4 deletions Stardust.Server/Services/NodeStatService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,12 +499,17 @@ private void ProcessorStat(DateTime date, ConcatExpression selects)
p = name.IndexOf("Platinum");
if (p > 0) name = name[p..].Trim();

// AMD Ryzen 7 2700 Eight-Core Processor
p = name.IndexOf("-Core");
if (p > 0) p = name.LastIndexOf(' ', p);
if (p > 0) name = name[..p].Trim();

var name2 = name
.TrimStart("AMD ", "Ryzen ", "EPYC", "Genuine ", "Intel(R) ", "Xeon(R) ", "Pentium(R) ", "Celeron(R) ", "CPU")
.TrimEnd(" Processor", "-Core", " v2", " v3", " v4", " 0", " (Device Tree)")
.TrimStart("AMD ", /*"Ryzen ",*/ /*"EPYC",*/ "Genuine ", "Intel(R) ", "Xeon(R) ", "Pentium(R) ", "Celeron(R) ", "CPU")
.TrimEnd(" Processor", /*"-Core",*/ " v2", " v3", " v4", " 0", " (Device Tree)")
.Trim();
if (name2.Contains("Ryzen"))
XTrace.WriteLine("{0} -> {1}", name, name2);
//if (name2.Contains("Ryzen"))
// XTrace.WriteLine("{0} -> {1}", name, name2);

node.Processor = name2;
}
Expand Down
2 changes: 1 addition & 1 deletion Stardust.Server/Stardust.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<ItemGroup>
<PackageReference Include="NewLife.IP" Version="2.1.2024.407" />
<PackageReference Include="NewLife.Redis" Version="5.6.2024.420-beta0005" />
<PackageReference Include="NewLife.Redis" Version="5.6.2024.508" />
</ItemGroup>

<ItemGroup>
Expand Down
24 changes: 24 additions & 0 deletions Stardust.ServerTests/Nodes/NodeStatTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Xunit;

namespace Stardust.ServerTests.Nodes;

public class NodeStatTests
{
[Fact]
public void Test1()
{
var name = "AMD Ryzen 7 2700 Eight-Core Processor";

var p = name.IndexOf("-Core");
if (p > 0) p = name.LastIndexOf(' ', p);
if (p > 0) name = name[..p].Trim();

Assert.Equal("AMD Ryzen 7 2700", name);
}
}
4 changes: 2 additions & 2 deletions Stardust.ServerTests/Stardust.ServerTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
Expand Down
2 changes: 1 addition & 1 deletion Stardust.Web/Areas/Nodes/Controllers/NodeStatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public String Resolve(DataField field, IModel data)
"城市" => $"/Nodes/Node?areaid={st.LinkItem}",
"芯片架构" => $"/Nodes/Node?arch={st.LinkItem}",
"项目" => $"/Nodes/Node?projectId={st.LinkItem}",
_ => df.Url,
_ => $"/Nodes/Node?q={st.LinkItem}",
};
}

Expand Down
2 changes: 1 addition & 1 deletion Stardust.Web/Stardust.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

<ItemGroup>
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.429-beta0850" />
<PackageReference Include="NewLife.Redis" Version="5.6.2024.420-beta0005" />
<PackageReference Include="NewLife.Redis" Version="5.6.2024.508" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 886914b

Please sign in to comment.