-
-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #773 from Cysharp/feature/MemoryProfilerApi
Use Profiler API with PerformanceTest
- Loading branch information
Showing
7 changed files
with
106 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
perf/BenchmarkApp/PerformanceTest.Server/PerfTestControlService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using JetBrains.Profiler.Api; | ||
using MagicOnion; | ||
using MagicOnion.Server; | ||
using PerformanceTest.Shared; | ||
|
||
namespace PerformanceTest.Server; | ||
|
||
public class PerfTestControlService : ServiceBase<IPerfTestControlService>, IPerfTestControlService | ||
{ | ||
public UnaryResult<ServerInformation> GetServerInformationAsync() | ||
{ | ||
return UnaryResult.FromResult(new ServerInformation( | ||
Environment.MachineName, | ||
ApplicationInformation.Current.MagicOnionVersion, | ||
ApplicationInformation.Current.GrpcNetVersion, | ||
ApplicationInformation.Current.MessagePackVersion, | ||
ApplicationInformation.Current.MemoryPackVersion, | ||
ApplicationInformation.Current.IsReleaseBuild, | ||
ApplicationInformation.Current.FrameworkDescription, | ||
ApplicationInformation.Current.OSDescription, | ||
ApplicationInformation.Current.OSArchitecture, | ||
ApplicationInformation.Current.ProcessArchitecture, | ||
ApplicationInformation.Current.IsServerGC, | ||
ApplicationInformation.Current.ProcessorCount, | ||
ApplicationInformation.Current.IsAttached)); | ||
} | ||
|
||
public UnaryResult SetMemoryProfilerCollectAllocations(bool enable) | ||
{ | ||
MemoryProfiler.CollectAllocations(enable); | ||
return UnaryResult.CompletedResult; | ||
} | ||
|
||
public UnaryResult CreateMemoryProfilerSnapshotAsync(string name) | ||
{ | ||
MemoryProfiler.GetSnapshot(name); | ||
return UnaryResult.CompletedResult; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
perf/BenchmarkApp/PerformanceTest.Shared/IPerfTestControlService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using MagicOnion; | ||
using MemoryPack; | ||
using MessagePack; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace PerformanceTest.Shared; | ||
|
||
public interface IPerfTestControlService : IService<IPerfTestControlService> | ||
{ | ||
UnaryResult<ServerInformation> GetServerInformationAsync(); | ||
|
||
UnaryResult SetMemoryProfilerCollectAllocations(bool enable); | ||
UnaryResult CreateMemoryProfilerSnapshotAsync(string name); | ||
} | ||
|
||
[MessagePackObject(true)] | ||
[MemoryPackable] | ||
public partial class ServerInformation | ||
{ | ||
public string MachineName { get; set; } | ||
public string? MagicOnionVersion { get; } | ||
public string? GrpcNetVersion { get; } | ||
public string? MessagePackVersion { get; } | ||
public string? MemoryPackVersion { get; } | ||
public bool IsReleaseBuild { get; } | ||
public string FrameworkDescription { get; } | ||
public string OSDescription { get; } | ||
public Architecture OSArchitecture { get; } | ||
public Architecture ProcessArchitecture { get; } | ||
public bool IsServerGC { get; } | ||
public int ProcessorCount { get; } | ||
public bool IsAttached { get; } | ||
|
||
public ServerInformation(string machineName, string? magicOnionVersion, string? grpcNetVersion, string? messagePackVersion, string? memoryPackVersion, bool isReleaseBuild, string frameworkDescription, string osDescription, Architecture osArchitecture, Architecture processArchitecture, bool isServerGC, int processorCount, bool isAttached) | ||
{ | ||
MachineName = machineName; | ||
MagicOnionVersion = magicOnionVersion; | ||
GrpcNetVersion = grpcNetVersion; | ||
MessagePackVersion = messagePackVersion; | ||
MemoryPackVersion = memoryPackVersion; | ||
IsReleaseBuild = isReleaseBuild; | ||
FrameworkDescription = frameworkDescription; | ||
OSDescription = osDescription; | ||
OSArchitecture = osArchitecture; | ||
ProcessArchitecture = processArchitecture; | ||
IsServerGC = isServerGC; | ||
ProcessorCount = processorCount; | ||
IsAttached = isAttached; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters