This Tag is used for two things: Questions regarding improving execution speed and questions where various methods are compared for execution speed.

learn more… | top users | synonyms

20
votes
2answers
300 views

Incorrect Timing of Total

For demonstrating how fast C-compiled functions can be, in one of my courses I use the following function for finding the sum of a list of reals: ...
17
votes
3answers
332 views

sudden increase in timing when summing over 250 entries

I see a sudden increase of Timing by a factor of thousands when I sum over 250 elements of a matrix rather than over 249. So for instance, this table contains sums ...
14
votes
1answer
260 views

Baffling increase in runtime

Background of my question I discovered Project Euler today, and decided I would work through the problems in Mathematica. I became obsessed with the first problem, which is essentially "sum all the ...
11
votes
3answers
321 views

Intermediate display similar to PrintTemporary

Using MMA we often come across situations like the following cityLIST = CityData[#, "Name"] & /@ CityData[]; This code if you evaluate will emit some display ...
11
votes
2answers
662 views

Why is ParallelMap way slower than Map

I recently tried to use ParallelMap instead of Map and to my surprise encountered that ...
9
votes
1answer
190 views

In version 10 EvaluationCompletionAction “ShowTiming” no longer gives useful output; any solutions?

Bug introduced in 10.0.0, fixed in 10.0.2 In version 10 using this Front End option no longer gives useful output: ...
7
votes
2answers
137 views

Syntactic Sugar for TestReports

Seems to me that VerificationTests are a bit verbose: ...
7
votes
4answers
229 views

Getting AbsoluteTiming to display in hours, minutes, and seconds

I'm doing some extended length calculations and was wondering how I could get AbsoluteTiming to display in hours, minutes, and seconds. I googled and found nothing, ...
6
votes
1answer
740 views

Simple countdown timer in Mathematica

I dug around a bit and did not find a simple and clear implementation of countdown stopwatch in Mathematica. I am looking for a function that takes as an input a certain integer and then counts down ...
6
votes
1answer
101 views

Why is CurrencyConvert so slow?

...
5
votes
1answer
276 views

Function takes hugely different times to evaluate on sets of virtually (but also literally) identical data

I'm experiencing something which I believe to be weird with a function that I wrote. Briefly: what happens is that I generate random data to feed my function in two different but equivalent ways (...
5
votes
1answer
250 views

Timing differences between multiple executions of identical code

I have a list of pairs of numbers and I'd like to change the sign of the second element in each pair i.e. $(a,b)\rightarrow (a,-b)$. I'm sure there are many ...
5
votes
1answer
85 views

Is it possible to use a function for EdgeWeight in a Graph?

Why I cannot calculate all edge weights beforehand: I have many large graphs for which I'd like to find the shortest path between two vertices (FindShortestPath ...
5
votes
1answer
149 views

Systematic increase in runtime [duplicate]

When I run this simple code, which repeats many times the exact same operation (a differential equation), the runtime (given by Timing) increases systematically, ...
4
votes
2answers
103 views

How can I pass arguments to Module without being reinterpreted each time they appear inside it?

I'm trying to understand how to save time when calling functions in Mathematica. I wrote this example, ...
4
votes
3answers
166 views

Problem with Conditionals: Why does mathematica add an extra empty list to my output

I have a set of positions where I want to slice a list of numbers. If I Total the values in that list, and they are greater than or equal to 1, I want to remember ...
4
votes
1answer
108 views

Strange behavior of Mathematica regarding calculation time

Today I witnessed the following strange behavior of Mathematica, when it comes to calculation time involving larger nested lists. The following is the short example that I setup, I am sure one can ...
4
votes
1answer
166 views

Timing mathematica code

I have a collection of functions (Modules) and I wish to find out which sub-routines inside the code take up most time. I have done this by wrapping individual code blocks with ...
4
votes
1answer
150 views

TimeConstrained for parallel computations

The Mathematica manual states TimeConstrained takes account only of CPU time spent inside the main Mathematica kernel process; it does not include additional ...
3
votes
2answers
134 views

Reflecting lines in ellipses: speed up the code?

I have the following code which calculates a list of points that a line would take after bouncing off various ellipses. ...
3
votes
2answers
566 views

How can I track the execution time of an evaluating Manipulate cell?

In Wolfram's tutorial on Advanced Manipulate Functionality, a nice example of a continually evaluating Manipulate cell is presented: ...
3
votes
1answer
175 views

Precise Timing for nested functions, how to? [duplicate]

Possible Duplicate: Profiling from Mathematica How can I easily get fractions of timing for each nested function? Consider a nested call like this: ...
2
votes
2answers
282 views

Good coding for a sequence of derivatives

People on this site keep telling me that good MMa practice avoids the use of loops. The code below calculates the same Table of derivatives two different ways, ...
2
votes
1answer
391 views

Understanding execution time in nested loops

I have the following simple code ...
2
votes
1answer
120 views

Graphing the amount of time a function takes

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 ...
2
votes
3answers
90 views

Reduction of repetitive calculations in Table

If I generate two tables inside a function which are function[n_, x_, y_]:=( table1 = Table[i* x/n^x, {i,1,n}]; table2 = Table[i* y/n^y, {i,1,n}]; ) where <...
2
votes
1answer
151 views

A question about definite integrals and timing

I need to integrate the expression G given below: ...
2
votes
1answer
245 views

How can I reduce computation time while still obtaining a good approximation for my function?

I am new to any CAS (and Mathematica, for that matter) and new to StackExchange too, so forgive me and correct me on any mistakes. I have this function: $J_p=\sum_{m,n=1}^{\infty} \epsilon_{mn}f_{mn}\...
2
votes
1answer
104 views

A problem with Timing

With M = Partition[Range@10000000, 1000]; V = Range[10000] - 1; I got the following timings: ...
2
votes
1answer
104 views

File output and race conditions

Is it possible to know when Mathematica is done writing a file? I'm looking to automate something and I'm wanting to have Mathematica put it in a file using Put[], ...
2
votes
0answers
41 views

Differences in AbsoluteTiming for similar codes

Consider the two following codes with the same SeedRandom (which ensures the same set of random numbers) but different use of the ...
2
votes
0answers
62 views

Why is this function taking so much more time when its argument reaches 250? [duplicate]

I am observing something which I do not understand with the following function function: ...
2
votes
0answers
90 views

Optimization of custom probability distibutions?

Consider the two tests: Timing[Do[RandomVariate[NormalDistribution[0.5, 0.3]], {200}]] {0.001188, Null} ...
1
vote
1answer
86 views

Why does Timing return different times for the same calculation?

I did an experiment in which I calculated the same quantity two different ways to see which method was faster. To my surprise, the kernel time was different in different runs. In fact, which method ...
1
vote
1answer
108 views

Strange timings of integrals involving Hermite's polynomials

I have used Mathematica to calculate tunneling for quantum harmonic oscillator. The code is simple: ...
1
vote
1answer
53 views

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 ...
1
vote
1answer
105 views

Evaluation time is always 0.23 s [closed]

Following the instructions in this documentation page, I'm setting EvaluationCompletionAction -> "Show Timing" in the option inspector so that Mathematica prints ...
1
vote
1answer
88 views

Calculating a multiplication of large number of matrices takes a long time [duplicate]

I have a multiplication of matrices, say M1.G1.M2.G2.....Mn.Gn, here n may reach 100. M and G are 4 4 matrices and their elements are function of s. Mathematica takes so long to perform this ...
1
vote
1answer
94 views

Interpolation function evaluation and timing

Lets define two identical functions $f$ and $g$ in a slightly different way ...
1
vote
0answers
64 views

Is Daylight Savings Time accounted for when using AbsoluteTime[]? [closed]

I have been running rather long computations lately and timing them using AbsoluteTime[] by calling it at the start and end of the computation. ...
0
votes
1answer
191 views

Slow evaluation of complicated Table

I have a system of recursive equations x[t+1]:=f[x[t],p[t-1],a[t],a[t-1]]; p[t+1]:=g[p[t],x[t-1],a[t],a[t-1]]; a[t+1]:=h[x[t],p[t],a[t],a[t-1]]; I want to ...
0
votes
0answers
18 views

What is the correct way to control thread parallelism?

I was trying to benchmark a program I have writing against Mathematica (or better said the internal Kernels used, like MKL). Since my program is not threaded I wanted to compare with Mathematica 10 ...
0
votes
0answers
61 views

frequent slow evaluations for trivial expressions, large memory loaded

After loading a lot of data into memory and evaluating several hundred expressions without any problems, trivial expressions such as (1+2) take about 5-10 seconds to evaluate. Sometimes they are fast,...
0
votes
0answers
44 views

Timing of associated Legendre polynomials

I encountered a strange issue with the associated Legendre polynomials implemented with LegendreP[l,m,z]. Quite simply, the time used for the numerical computation of those quantities depends on ...
0
votes
0answers
166 views

How to determine how much time it will take to finish a cell expression?

I am trying to integrate a large matrix with elements that contain trigonometric expressions. The evaluation is taking a long time--4 days, and it is still running. Is there anything I can do to find ...
0
votes
0answers
56 views

Interrupting FactorInteger automatically when it takes a very long time [duplicate]

Sometimes when I use FactorInteger[] with certain very big integers, it takes a very long time, and I have to interrupt the operation manually to try another ...
-1
votes
1answer
164 views

Plot CPU time vs iteration? [duplicate]

I would like to generate a plot of CPU time vs number of iterations. For example, if I were to calculate the solution of a system of differential equations in state-space form using the summation of e^...