58 lines
2.2 KiB
C#
58 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ShrinkModFramework
|
|
{
|
|
public sealed class ShrinkExternalAssemblyRevisionDiagnostic
|
|
{
|
|
internal ShrinkExternalAssemblyRevisionDiagnostic(string path, string revision, string assemblyName,
|
|
long loadedBytes, bool isCurrent)
|
|
{
|
|
Path = path;
|
|
Revision = revision;
|
|
AssemblyName = assemblyName;
|
|
LoadedBytes = loadedBytes;
|
|
IsCurrent = isCurrent;
|
|
}
|
|
|
|
public string Path { get; }
|
|
public string Revision { get; }
|
|
public string AssemblyName { get; }
|
|
public long LoadedBytes { get; }
|
|
public bool IsCurrent { get; }
|
|
}
|
|
|
|
/// <summary>Mono 外部程序集的 current 与常驻历史快照;LoadedBytes 仅统计载入 DLL/PDB 文件大小。</summary>
|
|
public sealed class ShrinkExternalAssemblyDiagnostic
|
|
{
|
|
internal ShrinkExternalAssemblyDiagnostic(int currentRevisionCount,
|
|
IReadOnlyList<ShrinkExternalAssemblyRevisionDiagnostic> residentRevisions,
|
|
long estimatedResidentBytes, int softLimit)
|
|
{
|
|
CurrentRevisionCount = currentRevisionCount;
|
|
ResidentRevisions = residentRevisions;
|
|
EstimatedResidentBytes = estimatedResidentBytes;
|
|
SoftLimit = softLimit;
|
|
}
|
|
|
|
public int CurrentRevisionCount { get; }
|
|
public IReadOnlyList<ShrinkExternalAssemblyRevisionDiagnostic> ResidentRevisions { get; }
|
|
public int ResidentRevisionCount => ResidentRevisions.Count;
|
|
public long EstimatedResidentBytes { get; }
|
|
public int SoftLimit { get; }
|
|
public bool IsSoftLimitExceeded => ResidentRevisionCount >= SoftLimit;
|
|
}
|
|
|
|
public static class ShrinkModDiagnostics
|
|
{
|
|
public static ShrinkExternalAssemblyDiagnostic CaptureExternalAssemblies(
|
|
ShrinkModFrameworkSettings settings = null)
|
|
{
|
|
if (settings == null)
|
|
settings = ShrinkModFrameworkSettings.Instance;
|
|
return ShrinkExternalModAssemblyLoader.CaptureDiagnostic(
|
|
settings != null ? settings.externalAssemblyRevisionSoftLimit : 16);
|
|
}
|
|
}
|
|
}
|