-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Benchmarks: X86 disassembler and rewriter.
- Loading branch information
Showing
3 changed files
with
102 additions
and
6 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,48 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Diagnosers; | ||
using Reko.Arch.X86; | ||
using Reko.Core; | ||
using Reko.Core.Memory; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.Design; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Reko.Benchmarks.Arch.X86 | ||
{ | ||
[Config(typeof(Config))] | ||
public class X86DisassemblerBenchmarks | ||
{ | ||
private readonly ByteMemoryArea machineCode; | ||
private readonly X86ArchitectureFlat32 arch; | ||
|
||
public X86DisassemblerBenchmarks() | ||
{ | ||
var mem = new byte[4096]; | ||
var rnd = new Random(0x142621A2); | ||
rnd.NextBytes(mem); | ||
this.machineCode = new ByteMemoryArea(Address.Ptr32(0x10000), mem); | ||
this.arch = new X86ArchitectureFlat32(new ServiceContainer(), "x86-protected-32", new()); | ||
} | ||
|
||
[Benchmark] | ||
public void DisassembleBytes() | ||
{ | ||
var rdr = arch.CreateImageReader(machineCode, 0); | ||
var dasm = arch.CreateDisassembler(rdr); | ||
foreach (var instr in dasm) | ||
; | ||
} | ||
|
||
public class Config : ManualConfig | ||
{ | ||
public Config() | ||
{ | ||
AddDiagnoser(MemoryDiagnoser.Default); | ||
} | ||
} | ||
} | ||
} |
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,51 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using Reko.Arch.X86; | ||
using Reko.Core.Memory; | ||
using Reko.Core; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.Design; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Diagnosers; | ||
using System.Reflection; | ||
|
||
namespace Reko.Benchmarks.Arch.X86 | ||
{ | ||
[Config(typeof(Config))] | ||
public class X86RewriterBenchmarks | ||
{ | ||
private readonly ByteMemoryArea machineCode; | ||
private readonly X86ArchitectureFlat32 arch; | ||
|
||
public X86RewriterBenchmarks() | ||
{ | ||
var mem = new byte[4096]; | ||
var rnd = new Random(0x142621A2); | ||
rnd.NextBytes(mem); | ||
this.machineCode = new ByteMemoryArea(Address.Ptr32(0x10000), mem); | ||
this.arch = new X86ArchitectureFlat32(new ServiceContainer(), "x86-protected-32", new()); | ||
} | ||
|
||
[Benchmark] | ||
public void LiftMachineCode() | ||
{ | ||
var rdr = arch.CreateImageReader(machineCode, 0); | ||
var rw = arch.CreateRewriter(rdr, arch.CreateProcessorState(), new StorageBinder(), new NullRewriterHost()); | ||
foreach (var rtlc in rw) | ||
; | ||
} | ||
|
||
public class Config : ManualConfig | ||
{ | ||
public Config() | ||
{ | ||
AddDiagnoser(MemoryDiagnoser.Default); | ||
} | ||
} | ||
|
||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.