# Timing and ListPlot

I am currently trying to examine the Timing function as it relates to generating primes and factorize large integers. What I want to do is to visualize how time grows as the numbers generated by RandomPrime grows using ListPlot. The naive approach is just to calculate several points using:

Timing[RandomPrime[{10^100, 100^101}]


and then change $100$ to, say, $200$, $300$, and so forth. But, this is a very ugly method.

Instead, what I would want to have a is a code that visualize the average of say 5 tries are taken for $\{10^{n},10^{n+1}\}$ for $n=100,200,\dots,1500$. How do I accomplish this?

You want to look at RepeatedTiming

Table[{n, First@RepeatedTiming[RandomPrime[{10^n, 100^(n + 1)}]]},
{n, 100, 1500, 100}]
(*{{100, 0.02}, {200, 0.1}, {300, 0.5}, {400, 0.9}, {500, 0.7}, {600,
5.}, {700, 1.*10^1}, {800, 1.*10^1}, {900, 3.*10^1}, {1000,
5.*10^1}, {1100, 51.}, {1200, 3.*10^1}, {1300, 7.*10^1}, {1400,
1.*10^2}, {1500, 1.*10^2}} *)


Then you can plot the results in a ListLogPlot

ListLogPlot[%, AxesLabel -> {"n", "Timing (s)"}]


• That is a very nice solution! Thanks! Before I accept it, may I ask why I get $10^100$ spanning to $10^2000$ on the Timing(s) axis when I use your input? Feb 8 '16 at 19:37
• It should read $10^{100}$ to $10^{2000}$. One thing that I noticed is that it, for some strange reason, does not seem to give the time on the $y$-axis. Feb 8 '16 at 19:47