Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 19991

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.

3 votes

FileNames becomes extremely slow when there are large number of files under a directory

Under windows system this is the way to get huge number of filenames under a directory: filenamesFast[dir_]:= Module[{txtname="\\temp-alldirs.txt"}, Run["dir \""<>dir<>"\" /b >\""<>dir<>txtname<>"\""] …
Harry's user avatar
  • 2,745
5 votes
1 answer
186 views

FileNames becomes extremely slow when there are large number of files under a directory

I have a directory on my portable hard drive, with around 350000 files under it (there is no subdirectory, only files). I want to get all the file dirs so use filedirs=FileNames["*",mydir] However, …
Harry's user avatar
  • 2,745
20 votes
1 answer
782 views

The efficiency compare between Flatten[#, 1] & and Join @@ # &

Err.. Often I met the situation to join lists at the first level and I used to just Flatten[#, 1] & @ them. However, I found (when glance over the mathematica.stackexchange.com) someone else prefers J …
Harry's user avatar
  • 2,745
12 votes
2 answers
311 views

why MeanFilter is nearly 100 times slower than MovingAverage for 1D array?

I used to average over my data with MeanFilter before I learn about MovingAverage and thought that these two functions are similar except that MeanFilter is more powerful for its ability to deal with …
Harry's user avatar
  • 2,745
3 votes
2 answers
93 views

union several arrays of same flag(date for example) efficiently

Suppose I have several arrays from data files which look like: arrayi = {{datei1, xi11, xi21, ...}, {datei2, xi12, xi22, ...}, ..., {datein, xi1n, xi2n ,...}} The arrayis are from different data so …
Harry's user avatar
  • 2,745
1 vote
1 answer
112 views

why URLFetch is slow when encapsulated by module and how to fix it [closed]

I'm using Mathematica 10.0.2 on Win7. I'm writing some program to crawl etymology of words on http://www.etymonline.com/. Below lies the example code: str = URLFetch[ "http://www.etymonline.com/inde …
Harry's user avatar
  • 2,745
1 vote
0 answers
46 views

Does NonlinearModelFit result stores FitResiduals? [closed]

I fits a long data series with a complex model by NonlinearModelFit: fitnlm = NonlinearModelFit[...] Then I can use fitnlm["BestFitParameters"] to get parameters, use fitnlm["Response"] to view ori …
Harry's user avatar
  • 2,745