summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-09-13 18:13:20 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-09-13 18:13:20 -0700
commit9ab60dabcca3d7c9fe9a0bb6e7e01f9295d95532 (patch)
tree865e67e81f3d555344409ce5a02d7d93db4b1653 /test
parent942acbf782256bf89d48e93c195966d820d29d49 (diff)
downloadnasm-9ab60dabcca3d7c9fe9a0bb6e7e01f9295d95532.tar.gz
nasm-9ab60dabcca3d7c9fe9a0bb6e7e01f9295d95532.tar.bz2
nasm-9ab60dabcca3d7c9fe9a0bb6e7e01f9295d95532.zip
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.
Diffstat (limited to 'test')
-rwxr-xr-xtest/perf/label.pl18
-rwxr-xr-xtest/perf/macro.pl18
-rwxr-xr-xtest/perf/token.pl23
3 files changed, 59 insertions, 0 deletions
diff --git a/test/perf/label.pl b/test/perf/label.pl
new file mode 100755
index 0000000..9b59768
--- /dev/null
+++ b/test/perf/label.pl
@@ -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";
+ }
+}
diff --git a/test/perf/macro.pl b/test/perf/macro.pl
new file mode 100755
index 0000000..b729805
--- /dev/null
+++ b/test/perf/macro.pl
@@ -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";
+ }
+}
diff --git a/test/perf/token.pl b/test/perf/token.pl
new file mode 100755
index 0000000..4a9e3ae
--- /dev/null
+++ b/test/perf/token.pl
@@ -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";
+}