public static void Write(string perfMapFileName, int perfMapFormatVersion, IEnumerable <MethodInfo> methods, IEnumerable <AssemblyInfo> inputAssemblies, TargetDetails details) { if (perfMapFormatVersion > CurrentFormatVersion) { throw new NotSupportedException(perfMapFormatVersion.ToString()); } using (TextWriter writer = new StreamWriter(perfMapFileName)) { PerfMapWriter perfMapWriter = new PerfMapWriter(writer); byte[] signature = PerfMapV1SignatureHelper(inputAssemblies, details); WritePerfMapV1Header(inputAssemblies, details, perfMapWriter); foreach (MethodInfo methodInfo in methods) { if (methodInfo.HotRVA != 0 && methodInfo.HotLength != 0) { perfMapWriter.WriteLine(methodInfo.Name, methodInfo.HotRVA, methodInfo.HotLength); } if (methodInfo.ColdRVA != 0 && methodInfo.ColdLength != 0) { perfMapWriter.WriteLine(methodInfo.Name, methodInfo.ColdRVA, methodInfo.ColdLength); } } } }
public static void Write(string perfMapFileName, IEnumerable <MethodInfo> methods) { using (TextWriter writer = new StreamWriter(perfMapFileName)) { PerfMapWriter perfMapWriter = new PerfMapWriter(writer); foreach (MethodInfo methodInfo in methods) { if (methodInfo.HotRVA != 0 && methodInfo.HotLength != 0) { perfMapWriter.WriteLine(methodInfo.Name, methodInfo.HotRVA, methodInfo.HotLength); } if (methodInfo.ColdRVA != 0 && methodInfo.ColdLength != 0) { perfMapWriter.WriteLine(methodInfo.Name, methodInfo.ColdRVA, methodInfo.ColdLength); } } } }
public static void Write(string perfMapFileName, int perfMapFormatVersion, IEnumerable <MethodInfo> methods, IEnumerable <AssemblyInfo> inputAssemblies, TargetOS targetOS, TargetArchitecture targetArch) { if (perfMapFormatVersion > CurrentFormatVersion) { throw new NotSupportedException(perfMapFormatVersion.ToString()); } using (TextWriter writer = new StreamWriter(perfMapFileName)) { IEnumerable <AssemblyInfo> orderedInputs = inputAssemblies.OrderBy(asm => asm.Name, StringComparer.OrdinalIgnoreCase); PerfMapWriter perfMapWriter = new PerfMapWriter(writer); List <byte> inputHash = new List <byte>(); foreach (AssemblyInfo inputAssembly in orderedInputs) { inputHash.AddRange(inputAssembly.Mvid.ToByteArray()); } inputHash.Add((byte)targetOS); inputHash.Add((byte)targetArch); Guid outputGuid = new Guid(MD5.HashData(inputHash.ToArray())); perfMapWriter.WriteLine(outputGuid.ToString(), (uint)PseudoRVA.OutputGuid, 0); perfMapWriter.WriteLine(targetOS.ToString(), (uint)PseudoRVA.TargetOS, 0); perfMapWriter.WriteLine(targetArch.ToString(), (uint)PseudoRVA.TargetArchitecture, 0); perfMapWriter.WriteLine(CurrentFormatVersion.ToString(), (uint)PseudoRVA.FormatVersion, 0); foreach (MethodInfo methodInfo in methods) { if (methodInfo.HotRVA != 0 && methodInfo.HotLength != 0) { perfMapWriter.WriteLine(methodInfo.Name, methodInfo.HotRVA, methodInfo.HotLength); } if (methodInfo.ColdRVA != 0 && methodInfo.ColdLength != 0) { perfMapWriter.WriteLine(methodInfo.Name, methodInfo.ColdRVA, methodInfo.ColdLength); } } } }
private static void WritePerfMapV1Header(IEnumerable <AssemblyInfo> inputAssemblies, TargetDetails details, PerfMapWriter perfMapWriter) { byte[] signature = PerfMapV1SignatureHelper(inputAssemblies, details); // Make sure these get emitted in this order, other tools in the ecosystem like the symbol uploader and PerfView rely on this. // In particular, the order of it. Append only. string signatureFormatted = Convert.ToHexString(signature); PerfmapTokensForTarget targetTokens = TranslateTargetDetailsToPerfmapConstants(details); perfMapWriter.WriteLine(signatureFormatted, (uint)PerfMapPseudoRVAToken.OutputSignature, HeaderEntriesPseudoLength); perfMapWriter.WriteLine(CurrentFormatVersion.ToString(), (uint)PerfMapPseudoRVAToken.FormatVersion, HeaderEntriesPseudoLength); perfMapWriter.WriteLine(((uint)targetTokens.OperatingSystem).ToString(), (uint)PerfMapPseudoRVAToken.TargetOS, HeaderEntriesPseudoLength); perfMapWriter.WriteLine(((uint)targetTokens.Architecture).ToString(), (uint)PerfMapPseudoRVAToken.TargetArchitecture, HeaderEntriesPseudoLength); perfMapWriter.WriteLine(((uint)targetTokens.Abi).ToString(), (uint)PerfMapPseudoRVAToken.TargetABI, HeaderEntriesPseudoLength); }