{"id":229,"date":"2008-06-23T07:15:54","date_gmt":"2008-06-23T12:15:54","guid":{"rendered":"https:\/\/blogs.mathworks.com\/desktop\/2008\/06\/23\/profiling-using-run-configurations\/"},"modified":"2008-06-24T08:09:02","modified_gmt":"2008-06-24T13:09:02","slug":"profiling-using-run-configurations","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2008\/06\/23\/profiling-using-run-configurations\/","title":{"rendered":"Profiling using run configurations"},"content":{"rendered":"<p>We talk a lot about work flows here on the <i>Inside the MATLAB Desktop<\/i> blog, as well as ways you can streamline your interactions with MATLAB. For the Editor-centric folks in the audience, here&#8217;s a great way to integrate <a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/index.html?\/access\/helpdesk\/help\/techdoc\/matlab_env\/f9-17018.html\">Profiling<\/a> into your workflow using run configurations.<\/p>\n<p>Profiling run configurations will let you tweak the performance of your code more iteratively. You&#8217;ll be able to work from the Editor, press the run button, inspect the performance, and then go right back to your code to tweak it.<\/p>\n<p>To setup a profiling run configuration, start by opening the file you&#8217;d like to improve the performance of in the MATLAB Editor. Then, open the Configuration Editor by pressing the drop-down arrow on the run button <img decoding=\"async\"  border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/ken_orr_profiling_using_run_configurations\/run_button.jpg\">, and select <b><i>Edit Run Configurations for [your file]<\/i><\/b>. In the <b>MATLAB Expression<\/b> area, put the following commands, where <i>your_function<\/i> is the function to profile:<\/p>\n<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">\r\n<span style=\"color: #228B22\">% start profiling.<\/span>\r\nprofile on;\r\n<span style=\"color: #228B22\">% call your function here.<\/span>\r\nyour_function\r\n<span style=\"color: #228B22\">% stop profiling.<\/span>\r\nprofile off;\r\n<span style=\"color: #228B22\">% show the profile viewer.<\/span>\r\nprofile viewer;\r\n<\/pre>\n<\/div>\n<p>Which should look something like this:<\/p>\n<div align=\"center\"><a  href=\"https:\/\/blogs.mathworks.com\/images\/desktop\/ken_orr_profiling_using_run_configurations\/run_configuration_editor.jpg\"><img decoding=\"async\"  border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/ken_orr_profiling_using_run_configurations\/run_configuration_editor_small.jpg\"><\/a><\/div>\n<p>Close the Configuration Editor when your done.<\/p>\n<p>Back in the Editor, you can click the run button <img decoding=\"async\"  border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/ken_orr_profiling_using_run_configurations\/run_button.jpg\"> (or press F5) and your code will be profiled. The <a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/index.html?\/access\/helpdesk\/help\/techdoc\/matlab_env\/f9-17018.html#f9-17117\">Profiler<\/a> will popup after running your function, so you&#8217;ll be able to immediately inspect the results, teak your code and re-run your function. To prevent the Profiler from obscuring the Editor, try docking it in the Desktop. This is a great technique for iterativley improving your code&#8217;s performance.<\/p>\n<p>Check out the MATLAB documentation for more information on the <a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/index.html?\/access\/helpdesk\/help\/techdoc\/ref\/profile.html\"><tt>profile<\/tt><\/a> function.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We talk a lot about work flows here on the Inside the MATLAB Desktop blog, as well as ways you can streamline your interactions with MATLAB. For the Editor-centric folks in the audience, here&#8217;s&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2008\/06\/23\/profiling-using-run-configurations\/\">read more >><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[14,9],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/229"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=229"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/229\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}