Modifying your code to pre-allocate those matrices may help a lot. In particular, you are constructing new matrices to hold a lot of intermediate quantities. You are seeing a lot of allocations because your code really does allocate a lot of memory. Running your code in a function, I see 3.699408 seconds (41.60 k allocations: 3.787 GiB, 5.39% gc time) which is already quite close to what you reported MATLAB as giving. Instead, put the code you’re timing in a function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |