Profiling

June 20, 2011 at 10:20 pm (doing it wrong, matlab is bad at math)

Occasionally I try to work around problems with MATLAB’s shitty slow performance by using its “profiler.”

A profiler is simple in concept: It records how much time a program spends in various functions, so you can tell which ones are slowing you down. There are a couple of different ways to implement a profiler: You could arrange to interrupt the language runtime every millisecond or so and see what functions you’re in the middle of executing. Alternately, you could arrange to record the time every function call begins or ends. Both these techniques involve either instrumenting the runtime, or concurrency and runtime introspection — that’s the kind of runtime stuff that MATLAB doesn’t provide users access to, so instead of being able to actually write a profiler, we have to rely on what profiling ability TMW’s programmers have already built into the runtime.

But fundamentally, that’s the hard part. After you’ve instrumented your runtime and are recording data while the program runs, everything after that is just tabulating and adding up numbers.

Which leads me to ask, how the fuck is MATLAB fucking up at the “adding up numbers” part so badly?

No, I do not have 36 CPUs in my machine, and mainLoop>go does not recurse on itself at all, either.

what1.png

More after the jump…Oh! One twentieth of the calls to require take 50 times as long as twenty twentieths of them.

what2.png

In a new profiler run, everything that calls mainLoop>go is accounted for, Interestingly, we conclude this function accounts 94% of its time not being called at all.

what3.png

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.