mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-04-12 18:40:23 +08:00
Simple performance benchmarks: label, macro and token lookups
Simple scripts to generate performance benchmarks for label, macro and token lookups. The label and macro lookups are simple numerical sequences; it may be desirable to add some more sophisticated algorithms for producing tokens in case we want to compare different hash functions against each other.
This commit is contained in:
parent
942acbf782
commit
9ab60dabcc
18
test/perf/label.pl
Executable file
18
test/perf/label.pl
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# Generate a test case for label lookup performance
|
||||
#
|
||||
|
||||
($len) = @ARGV;
|
||||
$len = 100000 unless ($len);
|
||||
|
||||
print "\tbits 32\n";
|
||||
print "\tsection .data\n";
|
||||
print "\n";
|
||||
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
print "l$i:\n";
|
||||
for ($j = 0; $j < 8; $j++) {
|
||||
print "\tdd l", int(rand($i+1)), "\n";
|
||||
}
|
||||
}
|
18
test/perf/macro.pl
Executable file
18
test/perf/macro.pl
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# Generate a test case for macro lookup performance
|
||||
#
|
||||
|
||||
($len) = @ARGV;
|
||||
$len = 100000 unless ($len);
|
||||
|
||||
print "\tbits 32\n";
|
||||
print "\tsection .data\n";
|
||||
print "\n";
|
||||
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
print "%define m$i $i\n";
|
||||
for ($j = 0; $j < 8; $j++) {
|
||||
print "\tdd m", int(rand($i+1)), "\n";
|
||||
}
|
||||
}
|
23
test/perf/token.pl
Executable file
23
test/perf/token.pl
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# Generate a test case for token lookup performance
|
||||
#
|
||||
|
||||
@insns = qw(add sub adc sbb and or xor mov);
|
||||
@regs = qw(eax ebx ecx edx esp ebp esi edi);
|
||||
|
||||
srand(0);
|
||||
sub pickone(@) {
|
||||
return $_[int(rand(scalar @_))];
|
||||
}
|
||||
|
||||
($len) = @ARGV;
|
||||
$len = 1000000 unless ($len);
|
||||
|
||||
print "\tbits 32\n";
|
||||
print "\n";
|
||||
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
print "\t", pickone(@insns), " ",
|
||||
pickone(@regs), ",", pickone(@regs), "\n";
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user