Sì, Wolfram Workbench ha un profiler, anche se according to the documentation l'output non è del tutto nella forma desiderata.
Devo notare che il problema sollevato da Mr.Wizard nei commenti - che i risultati memorizzati nella cache porteranno a risultati temporali diversi - può anche essere applicato nel profilo.
Se si voleva fare qualcosa di esclusivamente in Mathematica, si potrebbe provare qualcosa di simile:
myProfile[fun_Symbol,inputs_List]:=
TableForm[#[[{1,3,2}]]&/@ (Join @@@ ({Timing[f[#]],#} & /@ inputs))]
Se siete stati abbastanza felice di avere l'output come {tempistica, uscita, ingresso}, piuttosto che {tempistica, input, output} come specificato nella tua domanda, potresti liberarti del bit #[[{1,3,2}]]
.
EDIT
Dal momento che ho Banco di lavoro, ecco un esempio. Ho un pacchetto che include una funzione CobwebPlot
(e sì, la funzione stessa potrebbe essere migliorata).
CobwebPlot[x_?MatrixQ, opts___Rule] /;
And @@ (NumericQ /@ Flatten[x]) :=
Module[{n, \[Theta]s, numgrids, grids, struts, gridstyle, min, max,
data, labels, epilabels, pad},
n = Length[First[x]];
\[Theta]s = (2 \[Pi])/n Range[0, n] + If[OddQ[n], \[Pi]/2, 0];
numgrids =
If[IntegerQ[#] && Positive[#], #,
NumberofGrids /.
Options[CobwebPlot] ] & @ (NumberofGrids /. {opts});
{min, max} = {Min[#], Max[#]} &@ Flatten[x];
gridstyle = GridStyle /. {opts} /. Options[CobwebPlot];
pad = CobwebPadding /. {opts} /. Options[CobwebPlot];
grids =
Outer[List, \[Theta]s, FindDivisions[{0, max + 1}, numgrids]];
struts = Transpose[grids];
labels = CobwebLabels /. {opts} /. Options[CobwebPlot];
epilabels =
If[Length[labels] == n,
Thread[Text[
labels, (1.2 max) Transpose[{Cos[Most[\[Theta]s]],
Sin[Most[\[Theta]s]]}]]], None];
data = Map[Reverse,
Inner[List, Join[#, {First[#]}] & /@ x, \[Theta]s, List], {2}];
Show[ListPolarPlot[grids, gridstyle, Joined -> True, Axes -> False,
PlotRangePadding -> pad],
ListPolarPlot[struts, gridstyle, Joined -> True, Axes -> False],
ListPolarPlot[data,
Sequence @@ FilterRules[{opts}, Options[ListPolarPlot]],
Sequence @@
FilterRules[Options[CobwebPlot], Options[ListPolarPlot]],
Joined -> True, Axes -> None] ,
If[Length[labels] == n, Graphics /@ epilabels,
Sequence @@ FilterRules[{opts}, Options[Graphics]] ]]
]
L'esecuzione del pacchetto in modalità debug
E poi l'esecuzione di questo notebook
ha pronunciato la seguente uscita.
correlati: http://stackoverflow.com/questions/3418892/profiling-memory-usage-in-mathematica – abcd
Vedere anche: http://stackoverflow.com/questions/4721171/performance-tuning-in-mathematica –
Tutti: Sto cercando di farlo con 'TraceScan' ma io sto incontrando il problema che Mathematica memorizza i risultati nella cache, quindi le chiamate sequenziali a 'Prime [13!]' ad esempio richiedono tempi molto diversi per la valutazione. –