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.

354 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
42
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 ...
36
votes
0answers
871 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 ...
19
votes
0answers
179 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,...
19
votes
0answers
313 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 ...
13
votes
0answers
135 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
273 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
226 views

Why is MemoryInUse[] Very Different from the Actual Amount of Memory Being Used?

I call the MemoryInUse[] function, and it outputs about 256 Megabytes. MemoryInUse[] (*255979528*) However, my activity ...
12
votes
0answers
153 views

Linear programming with lazy constraints

Does Mathematica offer any means for solving linear programming problems with "lazy constraints", as described e.g. here? While I am not very familiar with linear programming, my understanding of the ...
12
votes
0answers
111 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
523 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
162 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
331 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
292 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
68 views

Different timing with large array assignment

Consider the following example n = 10^8; AbsoluteTiming[ A = ConstantArray[1., n]; // anyFunc; A[[2 ;; ;; 2]] = -1.; ] {0.388108, Null} ...
10
votes
0answers
142 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 ...
10
votes
0answers
221 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 ...
10
votes
0answers
320 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
569 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
95 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
152 views

What is the point of PaneSelector?

Intro PaneSelector looks like a pretty idiomatic way to toggle displayed content e.g.: ...
9
votes
0answers
123 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
209 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
196 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
112 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
112 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 ...
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
143 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
386 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 ...) ...
7
votes
0answers
1k 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
249 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
51 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
82 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
108 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, ...
6
votes
0answers
191 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
386 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
303 views

Challenge: Speeding up MaxDetect for application in 3D blob detection

In image segmentation it is a common problem that objects appear clustered and are therefore undistinguishable from each other when using simple algorithms. Based on this post I obtained efficient ...
6
votes
0answers
105 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
530 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
123 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
68 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
62 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
139 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
54 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
67 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
127 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
72 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
122 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
152 views

Improving the speed of an optimization algorithm via compilation and parallellization

I have written an implementation of eight variants of the PSO-algorithm and I want to test them over a set of test functions. I am using parallelization as it improves the speed a lot and I have also, ...
5
votes
0answers
351 views

Eigenvalues FEAST method - performance is very variable

I am running the FEAST method option for Eigenvalues on sparse matrices of dimension around 500,000. I look for about 50 ...

1
2 3 4 5
8