Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I know I can find out the amount of time a function takes to run like this:

In:=  function1[100] //Timing
Out:= {0.043334, Null}

How can I graph this over a set of 10 or 20 parameters (which are increasingly large), in order to get an idea of how the function scales?

share|improve this question
    
Did you mean to write function1[100]? –  s0rce Mar 8 '13 at 2:24
    
yes. New to mathematica - not used to square brackets. :) –  Jakob Weisblat Mar 8 '13 at 2:25
add comment

1 Answer

up vote 5 down vote accepted

This isn't the most exciting example but I hope it helps.

Use AbsoluteTiming to time the function and use Table to iterate over a set of values. We're simply going to time the Pause function which just waits x seconds, in this case x^2. The values will be stored as list. First gives us the first element of the output of AbsoluteTiming which is the time taken.

list = Table[First[AbsoluteTiming[Pause[x^2]]], {x, 0, 0.1, 0.01}];

Then we'll plot it with ListPlot

ListPlot[list]

Mathematica graphic

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.