Last active
December 24, 2015 06:49
-
-
Save simonjtyler/6759252 to your computer and use it in GitHub Desktop.
Some timings for http://mathematica.stackexchange.com/q/33223/34
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
In[1]:= n = 400; | |
In[2]:= TimeAv[Plus@@ReplaceList[Product[y[j], {j, 1, n}], y[i_] rest_ :> x[i] rest];] | |
During evaluation of In[2]:= Total wall time is 0.554032, | |
total cpu time is 0.530403 and total time spent evaluating the expression is 0.53040 | |
During evaluation of In[2]:= The expression was evaluated 6 times, without any blocking of the runs. | |
This yields a mean timing of 0.088401 with a standard deviation of 0.0074. | |
Out[2]= {0.088401, Null} | |
In[3]:= TimeAv[Sum[x[i] Product[y[j], {j, Delete[Range[n], i]}], {i, 1, n}];] | |
During evaluation of In[3]:= Total wall time is 0.652037, total cpu time is 0.639604 | |
and total time spent evaluating the expression is 0.60840 | |
During evaluation of In[3]:= The expression was evaluated 2 times, without any blocking of the runs. | |
This yields a mean timing of 0.304202 with a standard deviation of 0.14820. | |
Out[3]= {0.304202, Null} | |
In[4]:= TimeAv[Tr[Times@@@SparseArray[{{i_, i_} -> x@i, {i_, j_} -> y@j}, {n, n}]];] | |
During evaluation of In[4]:= Total wall time is 4.654266, total cpu time is 4.508429 | |
and total time spent evaluating the expression is 4.44603 | |
During evaluation of In[4]:= The expression was evaluated 10 times, without any blocking of the runs. | |
This yields a mean timing of 0.444603 with a standard deviation of 0.0290. | |
Out[4]= {0.444603, Null} | |
In[5]:= TimeAv[f = Array[x, n]; g = Array[y, n]; | |
Total[f[[#]] (Times @@ g)/g[[#]] & /@ Range[n]];] | |
During evaluation of In[5]:= Total wall time is 0.565032, total cpu time is 0.577204 | |
and total time spent evaluating the expression is 0.57720 | |
During evaluation of In[5]:= The expression was evaluated 3 times, without any blocking of the runs. | |
This yields a mean timing of 0.192401 with a standard deviation of 0.0074. | |
Out[5]= {0.192401, Null} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment