Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [performance-tuning]

Questions on optimizing Mathematica code for higher performance. This may mean faster execution, lower memory usage or both. Not to be confused with mathematical optimization.

48
votes
0answers
581 views

New Compiler Technology in V12

I am wondering whether the speed of compilation for the new compiler can be improved. Here are the results from my test. Consider the following function for generating a random draw from a gamma ...
40
votes
0answers
2k views

Mma 10: Half the parallel power (Macs)?

Here is a comparison of the parallel kernels launched under Mathematica under v9 and v10, on the same identical current 2014 R2-D2 Mac Pro ... [ Update: Valerio has commented that the same issue ...
38
votes
0answers
2k views

Fast Spherical Harmonics radiative transfer

This is a rather specific question and I apologize for spamming you with some lengthy code. But it could be interesting for some reader and maybe you can help out, so please bear with me. I am using ...
32
votes
0answers
820 views

Performance problems in new Sequence functions

The new-in-10.1 Sequence* family of functions should provide newly optimized methods for handling sequence problems. Happily in some cases they do! For example ...
27
votes
0answers
715 views

CPU timing for matrix rank calculation difference between 10.3 and 10.4 and 11.0

I run a small rank CPU test when new Mathematica version comes out. I noticed when version 10.1 came out that Mathematica rank calculation suddenly became extremely fast on a matrix when the size ...
18
votes
0answers
160 views

Inefficient memory storage for Dataset

Why Dataset doesn't serialize its contents, isn't it the whole point? I expect it to behave similar to python's pandas.DataFrame,...
18
votes
0answers
294 views

Internal`Bag memory usage

1. How does Internal`Bag handle memory inside a compiled function? (examples below) 2. Is there a way to explicitly free up memory used by ...
15
votes
0answers
529 views

Efficient solution of huge sparse linear system

I'm trying to improve efficiency of my code in which main task is a solution to huge (~$10^4\times 10^4$) but sparse linear system $$Ax=b$$ (In fact my aim is to solve nonlinear equations $F(x)=0$, ...
13
votes
0answers
127 views

Why does GreaterEqual take a long time to evaluate with arrays?

Take the following example: big = RandomReal[1, 10000000]; Head[big >= 0.66] // AbsoluteTiming (* {0.53489, GreaterEqual} *) Why does this take a long time ...
13
votes
0answers
269 views

Slow JoinAcross performance

Bug introduced in 10.3 I am using JoinAcross to combine two datasets, where the key is an Integer. ...
12
votes
0answers
99 views

What changed in String handling between 11.0 and 11.3?

I was trying to optimize some String-handling code here using my standard trick of converting it to a list of bytes first and using basic list operations instead of ...
11
votes
0answers
454 views

How to speed up calculations on big symbolic matrices?

this is my first time posting something on a community of the StackExchange platform, so please feel free to correct me if I'm doing something wrong. :) Additionally you should probably know that I'm ...
11
votes
0answers
159 views

Mathematica is getting slow when repeatedly calling an external program

I found a strange phenomenon that Mathematica is getting slow when I repeatedly called an external program by using ReadList. For example, the following code will display a significant increase of CPU ...
11
votes
0answers
319 views

Efficient image stacking

I have a list of lists of images that I would like to stack and create mean images for each list of images. Images are .jpg files 2592x1944 pixels large. Each list ...
11
votes
0answers
276 views

How to make Graphics3D with multiple lighting sources being rendered faster

I have a very "precise"(through setting "SpherePoints") Sphere illuminated by hundreds of random color lighting sources. The ...
10
votes
0answers
301 views

Improving the performance of a package for working with rational functions

As Mathematica gets slow for large symbolic calculations, the cost of putting terms over a common denominator (Together), in particular, gets too high. It occurred ...
10
votes
0answers
546 views

Faster simplification of linear combinations of some specific functions

After some profiling I've found that my program spends most of its time in the simplification step. The program uses my simplification function many times (over different data). My calculation is not ...
9
votes
0answers
96 views

CUDADot[] takes ~3x time compared to Dot[]

It all started when specifying TargetDevice -> "GPU" in Classify[] yielded no speedup nor any activity in the GPU. Then I tried something simpler like ...
9
votes
0answers
92 views

Predicting Pick performance

I'm trying to figure out how to use Pick most efficiently. I use it already in a number of places, but only ever in the context of ...
9
votes
0answers
116 views

Performance improvements by using Activate and Inactivate

In a question about improving performance of a TensorContract of a TensorProduct, user jose suggested replacing ...
9
votes
0answers
205 views

What are the time and space complexities of Classify/Predict?

Does anyone have knowledge of the O(n) time & space complexities for various model types supported by Classify[] and ...
9
votes
0answers
156 views

More efficient way to generate lattice graph with edges between visible vertices?

Given a nXn lattice, I need to generate the graph such that there is an edge between two vertices iff they are directly "visible" to each other, i.e., there is no vertex between them. I'm using <...
8
votes
0answers
54 views

Performance warning using TakeList and All on big lists

According to Mathematica's own documentation, TakeList can operate with lists containing All. For example: ...
8
votes
0answers
123 views

What is the point of PaneSelector?

Intro PaneSelector looks like a pretty idiomatic way to toggle displayed content e.g.: ...
8
votes
0answers
187 views

Call Magma in Mathematica

I've written some code in Mathematica, related to some group theory questions I have. Subsequently, I found that part of the code could be significantly sped up if I could just call a routine in ...
8
votes
0answers
1k views

Poor CUDALink performance, when calling a kernel multiple times

When working on a project of mine I noticed that CUDALink shows very poor performance when calling CUDA kernels multiple times in a loop-construct. To demonstrate this I put together this little ...
7
votes
0answers
107 views

Fast find sublist in a list procedure (for packed arrays of integers)

I want to find a first position of sublist inside a list, where both lists are packed arrays of integers. A typical ...
7
votes
0answers
118 views

ParallelSubmit executes only on one kernel

I'm trying to use Parallesubmit to run some calculations in parallel, but it looks like all the calculations are evaluated at one kernel. Consider this example: <...
7
votes
0answers
143 views

Is this a reliable method for getting a list of very large primes?

As noted here, both PrimePi and Prime are documented as having their limits somwhere around $10^{15}.$ ...
7
votes
0answers
380 views

Visualization of traces of moving objects

An example movie which is made with the listed mathematica code below shows traces of moving objects: https://youtu.be/8jN2uuSHCEg (Melting ...) http://youtu.be/5ET62846C-I (Crystallisation ...) ...
6
votes
0answers
243 views

Butter side up?

I've written a piece of code that determines if a piece toast with butter lands on the butter-side or not, depending on its initial velocity and the table height. If you are interested in the physics ...
6
votes
0answers
46 views

Graphics Primitive Selector

Goal and motivation I want to build something that would intuitively work like: Graphics @ PaneSelector[{True -> something, False -> {}}, Dynamic @ show] ...
6
votes
0answers
72 views

Querying vertex properties on graphs whose vertices are lists

Bug introduced in 10.0 or earlier and fixed in 11.3 Cross-posted on Wolfram Community Consider the following graph with the vertex property "foo". ...
6
votes
0answers
180 views

Improve recursive function (memoization)

These days I am trying to rewrite the following recursive function, in order to gain some speed. It is crucial because I end up using 4-5 similar functions, and I need to decrease execution time. ...
6
votes
0answers
383 views

Problems extending NelderMeadMinimize into 2D

Update The eventual route I followed was to adapt a version of the NM-simplex written in C and link to it with MathLink. Once I've tested this out fully I'll post it here. I've been playing around ...
6
votes
0answers
959 views

Performance tuning - Explicitly set Mathematica use Nvidia GPU for rendering

I feel hesitated to ask this question, but I cannot figure out a way to increase the performance. The problem is about running this featured example on a computer with both Intel HD GPU and Nvidia ...
6
votes
0answers
104 views

Does one need to be careful about loading multiple (many) contexts or packages in the same session?

I have a number of large pieces of precomputed data which I am considering putting into individual packages in order to load them (via DeclarePackage) and unload ...
6
votes
0answers
524 views

Parallelizing is much slower than single kernel evaluation?

Starting with a vector of matrices, tVec, I would like to parallelize the multiplication of each element with the same matrix ...
5
votes
0answers
104 views

Optimize Use of PeakDetect in Mathematica

I am quite new to Mathematica and I am looking for some advice in order to improve and optimize my code. Here is what I am trying to do: Open a stream Read the stream line by line and store it in "...
5
votes
0answers
62 views

How to prevent the message: Not enough memory to display a cell

While running a single-cell GUI application that repeatedly changes and refreshes its content I got this message: There was not enough memory to display a cell... I found in this old MathGroup thread ...
5
votes
0answers
61 views

How can I make this function definition more efficient?

I have a function $g(E)$ that is defined by a very complicated expression but that only involves built-in functions and integrations. I would like to define it in the absolute most efficient way ...
5
votes
0answers
125 views

How to efficiently apply PCA followed by SVD to extract the components of PCA?

I am working on segmenting a textured image using Gabor Filters. This is based on this paper. There exist a Matlab implementation of this as well. Earlier I managed to do up to this. With the help of ...
5
votes
0answers
52 views

Resize performance related to Ticks/Frame presence in Graphics

EDIT With Halirutan's help I have now a minimal example that exhibits the problem on every Windows machine I have. I have an OS/software specific problem with performance: The left one is smooth and ...
5
votes
0answers
66 views

Handling rendering delays gracefully

I moved the second issue to a separate topic: 162013 Please run the code sample As you can see there is a delay between the moment the calculation is finished and when the graphics is shown. And ...
5
votes
0answers
122 views

Speed up computing the $n$-th hexadecimal digits of $\pi$, by using BBP formula

Let $$S_j=\sum_{k=0}^{\infty} \frac{1}{16^k(8k+j)}$$ Then $(n+1)$-th hexadecimal digit of $\pi$ given by the fractional part of $${\lbrace 4\lbrace 16^{n} S_1\rbrace-2\lbrace 16^{n} S_4\rbrace-\...
5
votes
0answers
100 views

Smoothing out DensityPlot3D over a region quickly

Is there a way to smooth out DensityPlot3D over a region quickly in an aesthetic way? I can set PlotPoints to 100 or even 200, ...
5
votes
0answers
70 views

Inconsistent performance of code

I'm trying to do some optimizations to my code to make it run faster, but it seems that there are inconsistencies in the performance of the code. Namely, the codes have different performance in ...
5
votes
0answers
118 views

Is it possible to speedup these simple linear algebra operations

I'm trying to numerically solve some equations using splitting operator method. The solver I construct iteratively constructs a matrix and feeds it to LinearSolve. ...
5
votes
0answers
104 views

How to speed up solution of system of recurrence equations

I was wondering how I can improve the speed on this method for solving a particular system of coupled recurrence equations. The system is $$ \begin{align*} &V(m)=\alpha + \beta V(m+1)+\beta \sum_{...
5
votes
0answers
473 views

Module in numerical model for NonlinearModelFit is slow and leaks memory

I am trying to make a NonlinearModelFit where the model is the result of a numerical calculation. My code works, but it is very slow and also seems to have a memory ...