-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize loading of Relocation/Symbol tables
- Loading branch information
Showing
9 changed files
with
237 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\LibObjectFile\LibObjectFile.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,58 @@ | ||
// Copyright (c) Alexandre Mutel. All rights reserved. | ||
// This file is licensed under the BSD-Clause 2 license. | ||
// See the license.txt file in the project root for more information. | ||
|
||
using System.Diagnostics; | ||
using LibObjectFile.Elf; | ||
|
||
namespace LibObjectFile.Bench; | ||
|
||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var clock = Stopwatch.StartNew(); | ||
//var memoryStream = new MemoryStream(); | ||
foreach (var file in GetLinuxBins()) | ||
{ | ||
//memoryStream.SetLength(0); | ||
using var stream = File.OpenRead((string)file[0]); | ||
//stream.CopyTo(memoryStream); | ||
|
||
if (ElfFile.IsElf(stream)) | ||
{ | ||
ElfFile.Read(stream); | ||
} | ||
} | ||
clock.Stop(); | ||
Console.WriteLine($"{clock.Elapsed.TotalMilliseconds}ms"); | ||
} | ||
|
||
public static IEnumerable<object[]> GetLinuxBins() | ||
{ | ||
var wslDirectory = @"\\wsl$\Ubuntu\usr\bin"; | ||
if (OperatingSystem.IsLinux()) | ||
{ | ||
foreach (var file in Directory.EnumerateFiles(@"/usr/bin")) | ||
{ | ||
yield return new object[] { file }; | ||
} | ||
} | ||
else if (OperatingSystem.IsWindows() && Directory.Exists(wslDirectory)) | ||
{ | ||
foreach (var file in Directory.EnumerateFiles(wslDirectory)) | ||
{ | ||
var fileInfo = new FileInfo(file); | ||
// Skip symbolic links as loading them will fail | ||
if ((fileInfo.Attributes & FileAttributes.ReparsePoint) == 0) | ||
{ | ||
yield return new object[] { file }; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
yield return new object[] { string.Empty }; | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.