Mathematica Benchmarktest 
(Version 5)
created 9th of September 2007 by Stefan Steinhaus

Note : Version 5 of this benchmark test became necessary since the old version was old-fashioned and the timings were too low to be used seriously.
In the 5th edition of the benchmark test a lot of functions have been update but also several have been replaced by more complex functions. Please use this benchmark test only in connection with Mathematica 6.0 or higher.

Note: You should have a computer with at least 1GB of RAM and clock speed of more then 2 GHz to run this benchmark test.

Initialisation of global variables

$HistoryLength=3;
SeedRandom[4711];
tm={{"Test function","Your computer","AMD XP 2800+","Factor"},
{"","",""},
{"Creation,trans.,resh. of a matrix",0,127.156,0},
{"Sorting of values in asc. order",0,496.406,0},
{"680001!",0,190.734,0},
{"Check for Mersenne prime numbers",0,435.922,0},
{"Computation of Euler numbers",0,632.625,0},
{"Creation of a Hilbert matrix",0,363.985,0},
{"Comp. of Eigenvalues of matrix",0,304.218,0},
{"Build an orthogonal and normalized set of a matrix",0,434.797,0},
{"Numerical comp. of 6 triple integrals",0,551.469,0},
{"FFT and inverse FFT over 2^19 random values",0,388.000,0},
{"3-way ANOVA over 4 levels",0,669.344,0},
{"Expansion of a huge polynomial",0,521.328,0},
{"Comp. of a Laplace transformation",0,341.672,0},
{"Comp. of 6 Koch Snowflakes",0,450.766,0},
{"Array of Mandelbrot graphics",0,758.532,0},
{"Graphics array with pipes and Klein bottles",0,254.297,0},
{"Animation of a 3D Mountain in heatcolors",0,471.687,0},
{"","",""},
{"Total timing:",0,0,0}};

The delay factor is used to make the benchmark test easily convertab le to newer computer generations and/or newer Mathematica versions. With the current setting of DelayFactor = 150 the benchmark test is compatible to Mathematica 6 and computer generations with at least  1 GB RAM and a clock speed of 2 GHz and more. If you want to see the real calculation time for any of the functions please feel free to set the variable = 1.

DelayFactor=170;

BenchmarkVersion=5;

Misc. operation

Creation, trans. & reshaping of a 800x800 matrix

The following function creates a table of 800x800 real random numbers, takes the absolute value of them, transpose this matrix, flatten it to a list, partitions it to a 40x16.000 matrix. The timing will be calculated for doing this proccess <DelayFactor>*10 times.

tm[[3,2]]=Timing[Do[Transpose[Partition[Flatten[Transpose[Abs[RandomReal[{0,1},{800,800}]]]],40]];,{i,1,DelayFactor*10,1}]][[1]]/.Second->1;

200.000 values sorted in ascending order

The following function sorts <DelayFactor> lists of 200.000 random numbers and stores the timing for it.

tm[[4,2]]=Timing[Do[Sort[RandomReal[{0,1},{200000}],Greater];,{i,1,DelayFactor}]][[1]]/. Second->1;

Integer Computations

Simple mathematics

Computation of the factorial of 680.001.

tm[[5,2]]=Timing[Do[680001!;,{i,1,DelayFactor}]] [[1]]/. Second->1;

Number Theory

Check for Mersenne prime numbers

The following function checks the first <DelayFactor> * 400.000 numbers of the form x^2-1 whether they are a Mersenne prime number.

a:={};
tm[[6,2]]=Timing[Do[If[PrimeQ[j^2-1],AppendTo[a,j^2-1]],{j,DelayFactor*400000}]][[1]]/. Second->1;

Clear[a];

Computation of Euler numbers

The following function computes <DelayFactor> times a table with the first 10 Euler numbers of the polynomial n and stores only the timing.

tm[[7,2]]=Timing[Do[Table[EulerE[n,x],{n,0,370},{x,0,10}];,{i,1,DelayFactor}]][[1]]/. Second->1;

Linear Algebra

Computation of a 800x800 Hilbert matrix

The following function computes <DelayFactor> times a 800x800 Hilbert matrix, a special diagonal form of an integer matrix. Afterward the timing of this computation will be stored.

tm[[8,2]]=Timing[Do[HilbertMatrix[800];,{j,1,DelayFactor*3,1}]][[1]]/. Second->1;

Floating Point Computations

Linear Algebra

Computation of Eigenvalues of 500x500 matrix

The following function computes <DelayFactor> times a 500x500 random matrix, computes the Eigenvalues and stores the time for it.

tm[[9,2]]=Timing[Do[Eigenvalues[RandomReal[{0,1},{500,500}]],{i,1,DelayFactor}];][[1]]/.Second->1;

Build an orthogonal and nomalized set of a 800x800 matrix

The following function computes 100 times an orthogonal and normalized set of a 800x800 random matrix.

tm[[10,2]]=Timing[Do[Orthogonalize[RandomReal[{0,1},{800,800}],Method->"GramSchmidt"],{i,1,DelayFactor}];][[1]]/.Second->1;

Analysis

Numerical integration of 6 triple integrals

ℼ=N[π];

SetOpts[NIntegrate,o__?OptionQ]:=(oni=Options[NIntegrate];SetOptions[NIntegrate,o]);

ResetOpts[NIntegrate]:=SetOptions[NIntegrate,Sequence@@oni];

SetOpts[NIntegrate,PrecisionGoal->3];
tm[[11,2]]=Timing[Do[{
NIntegrate[Sin[x^2]+Sin[(y^2)]+Sin[(z^2)],{x,-ℼ,ℼ},{y,-ℼ,ℼ},{z,-ℼ,ℼ}],
NIntegrate[(3^(Cos[y]))+(4^(Sin[z]))+(5^(Sin[z])),{x,-ℼ,ℼ},{y,-ℼ,ℼ},{z,-ℼ,ℼ}],
NIntegrate[(2^(Log[(x^2)+(y^2)+(z^2)])),{x,-ℼ,ℼ},{y,-ℼ,ℼ},{z,0,ℼ}],
NIntegrate[Sin[(x^2)-(y^2)-(z^2)],{x,-ℼ,ℼ},{y,-ℼ,ℼ},{z,-ℼ,ℼ}],
NIntegrate[Cos[(x^2)+(y^2)+(z^2)],{x,-ℼ,ℼ},{y,-ℼ,ℼ},{z,-ℼ,ℼ}],
NIntegrate[Sin[(x^2)+(y^2)+(z^2)],{x,-ℼ,ℼ},{y,-ℼ,ℼ},{z,-ℼ,ℼ}]},{i,1,DelayFactor}];][[1]]/.Second->1;
ResetOpts[NIntegrate];

FFT and Inverse FFT over 2^19 random values

tm[[12,2]]=Timing[Do[InverseFourier[Chop[Fourier[RandomReal[{0,1},(2^19)]]]],{j,1,DelayFactor*2}];][[1]]/.Second->1;

Stochastic & statistic

3-way ANOVA with 4 levels

The following function computes an 3-way ANOVA with 4 levels over 30 random data sets.

Needs["ANOVA`"]

tm[[13,2]]=Timing[Do[ANOVA[Flatten[Flatten[Flatten[Table[Table[Table[Table[{j,h,g,RandomReal[]},{20}],{j,1,4}],{h,1,4}],{g,1,4}],1],1],1],{factor1,factor2,factor3,All},{factor1,factor2,factor3}],{i,1,DelayFactor}];][[1]]/.Second->1;

Remove[Statistics`ANOVA]

Symbolic Computations

Expansion of a huge polynomial

tm[[14,2]]=Timing[Table[Expand[Apply[Times,Table[x-(a+i/10),{a,1,20,0.02}]]],{i,1,DelayFactor,1}];][[1]]/.Second->1;

Computation of a multi-dimensional Laplace transformation

tm[[15,2]]=Timing[Do[LaplaceTransform[d Sin[(Sqrt[a t1])+(Sqrt[a t2])+(Sqrt[a t3])+(Sqrt[a t4])+(Sqrt[a t5])],{t1,t2,t3,t4,t5},{s1,s2,s3,s4,s5},DefiniteIntegral->True];,{i,1,DelayFactor*4}]][[1]]/.Second->1;

Graphics

2D Graphics

Computation of a Koch Snowflake

The boundary of the Koch Snowflake constructed by Helge Von Koch in 1904 is the union of three congruent self-similar fractals.  Each third of the snowflake is constructed by starting with one side of an equilateral triangle and performing an iterative process.  The following cell defines a function called Snowflake that illustrates the stages in this iterative process.

Programmcode

(*  Given a non-negative integer n, the function 
    Snowflake generates the nth level approximation 
    to the Koch Snowflake. Code from the Notices of 
    the AMS Vol.39 #7 Sept 92, page 709              *)
    
Clear[n,Snowflake,start,finish,doline]
Snowflake[n_Integer?NonNegative]:=
  Show[Graphics[
    Nest[ (#1/.Line[{start_,finish_}] :>doline[start,
             finish]) &,
          {Line[{{0,0},{1/2,Sqrt[3]/2}}],
           Line[{{1/2,Sqrt[3]/2},{1,0}}],
           Line[{{1,0},{0,0}}]},
          n]],
   AspectRatio->Automatic,PlotRange->All,DisplayFunction->Identity]

doline[start_,finish_]:=
  Module[{vec,norma},
  vec=finish-start;
  norma=Reverse[vec] {-1,1} Sqrt[3]/6;
  {Line[{start,start + vec/3}],
  Line[{start + vec/3,start + vec/2 + norma}],
  Line[{start + vec/2 + norma, start + 2 vec/3}],
  Line[{start + 2 vec/3, finish}]
  }
  ];

Computation for 6 flakes

tm[[16,2]]=Timing[Do[Snowflake[6];,{i,1,DelayFactor}]][[1]]/. Second->1;

Mandelbrot graphics

Calculates an array of 9 MAndelbrot graphics.

Mandelbrot[z_,c_,n_:20]:=Block[{res=(z^2)+c},If[Abs[res]>2,n,If[n<1,0,Mandelbrot[res,c,n-1]]]]

tm[[17,2]]=Timing[Do[GraphicsGrid[{{ContourPlot[Mandelbrot[0,a+b I],{a,-2,1},{b,-1.5`,1.5`},ContourStyle->None,PlotPoints->80,ColorFunction->Hue,DisplayFunction->Identity],ContourPlot[Mandelbrot[0,a+b I],{a,-2,-1},{b,-0.5`,0.5`},ContourStyle->None,PlotPoints->80,ColorFunction->Hue,DisplayFunction->Identity],ContourPlot[Mandelbrot[0,a+b I],{a,-1.5`,-1.2`},{b,-0.2`,0.2`},ContourStyle->None,PlotPoints->80,ColorFunction->Hue,DisplayFunction->Identity]},{ContourPlot[Mandelbrot[0,a+b I],{a,-1.5`,-1.45`},{b,-0.1`,0.1`},ContourStyle->None,PlotPoints->80,ColorFunction->Hue,DisplayFunction->Identity],ContourPlot[Mandelbrot[0,a+b I],{a,-1.49`,-1.45`},{b,-0.06`,0.06`},ContourStyle->None,PlotPoints->80,ColorFunction->Hue,DisplayFunction->Identity],ContourPlot[Mandelbrot[0,a+b I],{a,-1.49`,-1.47`},{b,-0.06`,0},ContourStyle->None,PlotPoints->80,ColorFunction->Hue,DisplayFunction->Identity]},{ContourPlot[Mandelbrot[0,a+b I],{a,-1.49`,-1.48`},{b,-0.05`,-0.03`},ContourStyle->None,PlotPoints->80,ColorFunction->Hue,DisplayFunction->Identity],ContourPlot[Mandelbrot[0,a+b I],{a,-1.49`,-1.488`},{b,-0.04`,-0.03`},ContourStyle->None,PlotPoints->80,ColorFunction->Hue,DisplayFunction->Identity],ContourPlot[Mandelbrot[0,a+b I],{a,-1.49`,-1.489`},{b,-0.038`,-0.034`},ContourStyle->None,PlotPoints->80,ColorFunction->Hue,DisplayFunction->Identity]}}];,{i,1,DelayFactor/30}]][[1]]/.Second->1;

3D Graphics

Graphics array with pipes and Klein bottles

bx=6 Cos[u] (1+Sin[u]);
by=16 Sin[u];
rad=4 (1-((Cos[u])/2));
X=If[π<u≤2 π,bx+rad Cos[v+π],bx+rad Cos[u] Cos[v]];
Y=If[π<u≤2 π,by,by+rad Sin[u] Cos[v]];
Z=rad Sin[v];

tm[[18,2]]=Timing[Do[GraphicsArray[{{ParametricPlot3D[{{Sin[t],u,Cos[t]},{Sin[t],Cos[t],u},{u,Sin[t],Cos[t]}},{t,-Pi,Pi},{u,-Pi,Pi},PlotPoints->100,DisplayFunction->Identity],ParametricPlot3D[{{Sin[t],u,Cos[t]},{Sin[t],Cos[t],u},{u,Sin[t],Cos[t]}},{t,-Pi,Pi},{u,0,2Pi},PlotPoints->100,DisplayFunction->Identity],ParametricPlot3D[{X,Y,Z},{u,0,2 π},{v,0,2 π},PlotPoints->{100,100},Axes->False,Boxed->False,ViewPoint->{1.4,-2.6,-1.7},DisplayFunction->Identity]},{ParametricPlot3D[{X,Y,Z},{u,0,2 π},{v,0,2 π},PlotPoints->{100,100},Axes->False,Boxed->False,ViewPoint->{1.4,-1.6,-1.7},DisplayFunction->Identity],ParametricPlot3D[{{Sin[t],u,Cos[t]},{Sin[t],Cos[t],u},{u,Sin[t],Cos[t]}},{t,-Pi,Pi},{u,-2Pi,0},PlotPoints->100,DisplayFunction->Identity],ParametricPlot3D[{{Cos[t],Pi-Sin[t],u},{u,Pi-Sin[t],Cos[t]},{Pi-Sin[t],u,Cos[t]}},{t,-Pi,Pi},{u,-Pi,Pi},PlotPoints->100,DisplayFunction->Identity]}}];,{i,1,DelayFactor/30}]][[1]]/. Second->1;

Clear[x,y,z,bx,by,rad]

Animations

3D Mountain in heatcolors

The following function will calculate an animation of a figure with heat colors.

<<Graphics`Graphics3D`

tm[[19,2]]=Timing[Do[ShadowPlot3D[ Exp[-z*(x^2 + y^2)],
             {x, -2, 2}, {y, -2, 2},PlotPoints->50,
               ShadowPosition -> 1,DisplayFunction->Identity],{z,0.1,1,0.08/DelayFactor}]][[1]]/. Second->1;

Remove[Graphics`Graphics3D]

Final results of the Benchmarktest

Display Benchmark results on screen

In this section a final analyze of the benchmark timings will be done. Information like the version of Mathematica, all resulting timings, the sum of the timings and a comparison timing will be displayed.

tm[[21,2]]=Sum[tm[[i,2]],{i,3,20,1}];
tm[[21,3]]=Sum[tm[[i,3]],{i,3,20,1}];
Do[tm[[i,4]]=tm[[i,3]]/tm[[i,2]],{i,3,19,1}];
tm[[21,4]]=tm[[21,3]]/tm[[21,2]];
Print["Mma. version   = ",$Version];
Print["Memory used    = ",MaxMemoryUsed[]];
Print["Delay factor   = ",DelayFactor];
Print["Benchmark ver. = ",BenchmarkVersion];
Print["\nTimings in seconds:\n","===================\n"];
Print[TableForm[tm]];

Save Benchmark results in a file

strm=OpenWrite["c:\\benchmatheresult.txt"]
WriteString[strm,"Mma. version   = ",$Version,"\n"];
WriteString[strm,"Memory used    = ",MaxMemoryUsed[],"\n"];
WriteString[strm,"Delay factor   = ",DelayFactor,"\n"];
WriteString[strm,"Benchmark ver. = ",BenchmarkVersion,"\n","\n"];
Do[
	WriteString[strm,tm[[x,1]],";",N[tm[[x,2]],4],"\n"],{x,3,19,1}]
WriteString[strm,tm[[21,1]],";",N[tm[[21,2]],4]]
Close[strm]

Feedback for Benchmark site

Dear Mathematica user in case you would like to add your Mathematica benchmark timings to the benchmark website then send the following information by email to stefan@steinhaus-net.de

Either copy & paste the results of the "Display Benchmark results on Screen" section or send the output file "benchmatheresult.txt"

Information about the computer you have used: Model type, processor (amount or processors, if more then one), clock speed, RAM, cache size

Mathematica version number

Your name and email address