-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
... based on old MatrixObj benchmarks I wrote years ago. I think it's useful to also have the benchmarks (including the old ones) permanently in the repo, so that we can measure for regressions and also create new benchmarks more easily.
- Loading branch information
Showing
3 changed files
with
450 additions
and
0 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,152 @@ | ||
ReadGapRoot("benchmark/matobj/bench.g"); | ||
|
||
|
||
TestReadingMatrix := function(m) | ||
local f; | ||
|
||
PrintHeadline("m[i][j]"); | ||
MyBench(function() | ||
local u, i, j, rows, cols, x; | ||
rows := [1..Length(m)]; | ||
cols := [1..Length(m[1])]; | ||
for u in [1..QuoInt(100000,Length(m)*Length(m[1]))] do | ||
for i in rows do | ||
for j in cols do | ||
x:=m[i][j]; | ||
od; | ||
od; | ||
od; | ||
end); | ||
|
||
PrintHeadline("m[i,j]"); | ||
MyBench(function() | ||
local u, i, j, rows, cols, x; | ||
rows := [1..Length(m)]; | ||
cols := [1..Length(m[1])]; | ||
for u in [1..QuoInt(100000,Length(m)*Length(m[1]))] do | ||
for i in rows do | ||
for j in cols do | ||
x:=m[i,j]; | ||
od; | ||
od; | ||
od; | ||
end); | ||
|
||
PrintHeadline("MatElm(m,i,j)"); | ||
MyBench(function() | ||
local u, i, j, rows, cols, x; | ||
rows := [1..Length(m)]; | ||
cols := [1..Length(m[1])]; | ||
for u in [1..QuoInt(100000,Length(m)*Length(m[1]))] do | ||
for i in rows do | ||
for j in cols do | ||
x:=MatElm(m,i,j); | ||
od; | ||
od; | ||
od; | ||
end); | ||
|
||
PrintHeadline("MatElm(m,i,j) with prefetched method"); | ||
f:=ApplicableMethod(MatElm, [m,1,1]);; | ||
MyBench(function() | ||
local u, i, j, rows, cols, x; | ||
rows := [1..Length(m)]; | ||
cols := [1..Length(m[1])]; | ||
for u in [1..QuoInt(100000,Length(m)*Length(m[1]))] do | ||
for i in rows do | ||
for j in cols do | ||
x:=f(m,i,j); | ||
od; | ||
od; | ||
od; | ||
end); | ||
|
||
end; | ||
|
||
TestWritingMatrix := function(m) | ||
local f; | ||
|
||
PrintHeadline("m[i][j]:=elm"); | ||
MyBench(function() | ||
local u, i, j, rows, cols, x; | ||
x:=m[1][1]; | ||
rows := [1..Length(m)]; | ||
cols := [1..Length(m[1])]; | ||
for u in [1..QuoInt(100000,Length(m)*Length(m[1]))] do | ||
for i in rows do | ||
for j in cols do | ||
m[i][j]:=x; | ||
od; | ||
od; | ||
od; | ||
end); | ||
|
||
PrintHeadline("m[i,j]:=elm"); | ||
MyBench(function() | ||
local u, i, j, rows, cols, x; | ||
x:=m[1][1]; | ||
rows := [1..Length(m)]; | ||
cols := [1..Length(m[1])]; | ||
for u in [1..QuoInt(100000,Length(m)*Length(m[1]))] do | ||
for i in rows do | ||
for j in cols do | ||
m[i,j]:=x; | ||
od; | ||
od; | ||
od; | ||
end); | ||
|
||
PrintHeadline("SetMatElm(m,i,j,elm)"); | ||
MyBench(function() | ||
local u, i, j, rows, cols, x; | ||
x:=m[1][1]; | ||
rows := [1..Length(m)]; | ||
cols := [1..Length(m[1])]; | ||
for u in [1..QuoInt(100000,Length(m)*Length(m[1]))] do | ||
for i in rows do | ||
for j in cols do | ||
SetMatElm(m,i,j,x); | ||
od; | ||
od; | ||
od; | ||
end); | ||
|
||
PrintHeadline("SetMatElm(m,i,j,elm) with prefetched method"); | ||
f:=ApplicableMethod(SetMatElm, [m,1,1,m[1][1]]);; | ||
MyBench(function() | ||
local u, i, j, rows, cols, x; | ||
x:=m[1][1]; | ||
rows := [1..Length(m)]; | ||
cols := [1..Length(m[1])]; | ||
for u in [1..QuoInt(100000,Length(m)*Length(m[1]))] do | ||
for i in rows do | ||
for j in cols do | ||
f(m,i,j,x); | ||
od; | ||
od; | ||
od; | ||
end); | ||
end; | ||
|
||
RunMatTest := function(desc, m) | ||
Print("\n"); | ||
PrintBoxed(Concatenation("Testing ", desc)); | ||
TestReadingMatrix(m); | ||
Print(TextAttr.2, "...now testing write access...\n", TextAttr.reset); | ||
TestWritingMatrix(m); | ||
end; | ||
|
||
m:=IdentityMat(10);; | ||
RunMatTest("integer matrix", m); | ||
|
||
m:=IdentityMat(10,GF(2));; | ||
RunMatTest("GF(2) rowlist", m); | ||
|
||
m:=IdentityMat(10,GF(2));; ConvertToMatrixRep(m);; | ||
RunMatTest("GF(2) compressed matrix", m); | ||
|
||
m:=IdentityMat(10,GF(7));; | ||
RunMatTest("GF(7) rowlist", m); | ||
|
||
m:=IdentityMat(10,GF(7));; ConvertToMatrixRep(m);; | ||
RunMatTest("GF(7) compressed matrix", m); |
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,113 @@ | ||
ReadGapRoot("benchmark/matobj/bench.g"); | ||
|
||
|
||
TestCreatingVector := function(v) | ||
Error("TODO"); | ||
end; | ||
|
||
# test for old-style matrix constructors, as reference | ||
TestCreatingMatrix := function(ring) | ||
PrintHeadline("NullMat"); | ||
MyBench(function() | ||
local m, n, mat; | ||
for m in [1..10] do | ||
for n in [1..10] do | ||
mat := NullMat(m, n, ring); | ||
od; | ||
od; | ||
end); | ||
|
||
PrintHeadline("IdentityMat"); | ||
MyBench(function() | ||
local n, mat; | ||
for n in [1..100] do | ||
mat := IdentityMat(n, ring); | ||
od; | ||
end); | ||
end; | ||
|
||
# test for matriobj constructors | ||
TestCreatingMatrixObj := function(filter, ring) | ||
local example_mat; | ||
|
||
example_mat := NewZeroMatrix(filter, ring, 1, 1); | ||
|
||
PrintHeadline("NewZeroMatrix"); | ||
MyBench(function() | ||
local m, n, mat; | ||
for m in [1..10] do | ||
for n in [1..10] do | ||
mat := NewZeroMatrix(filter, ring, m, n); | ||
od; | ||
od; | ||
end); | ||
|
||
PrintHeadline("ZeroMatrix( filt, R, m, n )"); | ||
MyBench(function() | ||
local m, n, mat; | ||
for m in [1..10] do | ||
for n in [1..10] do | ||
mat := ZeroMatrix(filter, ring, m, n); | ||
od; | ||
od; | ||
end); | ||
|
||
PrintHeadline("ZeroMatrix( m, n, M )"); | ||
MyBench(function() | ||
local m, n, mat; | ||
for m in [1..10] do | ||
for n in [1..10] do | ||
mat := ZeroMatrix(m, n, example_mat); | ||
od; | ||
od; | ||
end); | ||
|
||
PrintHeadline("NewIdentityMatrix"); | ||
MyBench(function() | ||
local n, mat; | ||
for n in [1..100] do | ||
mat := NewIdentityMatrix(filter, ring, n); | ||
od; | ||
end); | ||
|
||
PrintHeadline("IdentityMatrix( filt, R, n )"); | ||
MyBench(function() | ||
local n, mat; | ||
for n in [1..100] do | ||
mat := IdentityMatrix(filter, ring, n); | ||
od; | ||
end); | ||
|
||
PrintHeadline("IdentityMatrix( n, M )"); | ||
MyBench(function() | ||
local n, mat; | ||
for n in [1..100] do | ||
mat := IdentityMatrix(n, example_mat); | ||
od; | ||
end); | ||
|
||
# TODO: NewMatrix | ||
# TODO: Matrix | ||
end; | ||
|
||
RunMatTest := function(desc, ring) | ||
Print("\n"); | ||
PrintBoxed(Concatenation("Testing ", desc)); | ||
TestCreatingMatrix(ring); | ||
end; | ||
|
||
RunMatTest("GF(2)", GF(2)); | ||
RunMatTest("Rationals", Rationals); | ||
|
||
RunMatObjTest := function(desc, filter, ring) | ||
Print("\n"); | ||
PrintBoxed(Concatenation("Testing ", desc)); | ||
TestCreatingMatrixObj(filter, ring); | ||
end; | ||
|
||
RunMatObjTest("GF(2) IsPlistMatrixRep", IsPlistMatrixRep, GF(2)); | ||
RunMatObjTest("integer IsPlistMatrixRep", IsPlistMatrixRep, Integers); | ||
RunMatObjTest("rational IsPlistMatrixRep", IsPlistMatrixRep, Rationals); | ||
|
||
# TODO: other reps | ||
# TODO: other compare with creating plist-of-plist |
Oops, something went wrong.