<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.eiffelroom.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>eiffelroom - Profiling - Comments</title>
 <link>http://www.eiffelroom.com/blog/manus_eiffel/profiling</link>
 <description>Comments for &quot;Profiling&quot;</description>
 <language>en</language>
<item>
 <title>Definitely add the agent</title>
 <link>http://www.eiffelroom.com/blog/manus_eiffel/profiling#comment-357</link>
 <description>&lt;p&gt;The &lt;code class=&quot;geshifilter&quot;&gt;SHARED_PROFILE_SETTINGS&lt;/code&gt; idea is good. It would make it clear that this is a singleton setting. The current approach of creating a new object, which you then instruct to start and stop, is a bit weird. It feels like you are starting and stopping something local, but you have to imagine that the implementation is starting and stopping some global flag.&lt;/p&gt;

&lt;p&gt;The agent is a great idea. I&#039;ve used a similar pattern to ensure, for example, that an EiffelVision application&#039;s hourglass cursor gets reset to the the normal mouse cursor even if there&#039;s an exception. I&#039;ve noticed that Eiffel programmers tend to be lax at this, compared with good programmers in languages with &lt;code class=&quot;geshifilter csharp&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;try&lt;/span&gt;&lt;/code&gt;..&lt;code class=&quot;geshifilter csharp&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;finally&lt;/span&gt;&lt;/code&gt; at their disposal; partly because Eiffel&#039;s &lt;code class=&quot;geshifilter eiffel&quot;&gt;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;rescue&lt;/span&gt;&lt;/code&gt; mechanism is more heavy-handed in these situations; and partly because the Eiffel philosophy that exceptions are bugs tends to cause us to pretend that they will never happen. (I learned long ago that bugs often occur when you least expect them. That&#039;s what attracted me to DbC in the first place. It also made me paranoid about ensuring that resources are &lt;em&gt;always&lt;/em&gt; disposed or reset, even in the event of an exception.)&lt;/p&gt;

&lt;p&gt;Yet another example of the power of Eiffel idioms! I can&#039;t understand Colin&#039;s opinion that the &lt;code class=&quot;geshifilter csharp&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;try&lt;/span&gt;&lt;/code&gt;..&lt;code class=&quot;geshifilter csharp&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;finally&lt;/span&gt;&lt;/code&gt; code looks as complicated as Manu&#039;s &lt;code class=&quot;geshifilter eiffel&quot;&gt;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;rescue&lt;/span&gt;&lt;/code&gt; code, but Paul has shown a third way. I&#039;m more than happy with this idiom. I just wonder sometimes, however, whether the need to relearn stuff like this just raises too much of a learning barrier for those zillions of programmers out there who, like me, are comfortable with the &lt;code class=&quot;geshifilter csharp&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;try&lt;/span&gt;&lt;/code&gt;..&lt;code class=&quot;geshifilter csharp&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;finally&lt;/span&gt;&lt;/code&gt; idiom. Maybe someone will invent an even simpler way someday, that hides the &lt;code class=&quot;geshifilter eiffel&quot;&gt;&lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;rescue&lt;/span&gt;&lt;/code&gt; and the agent behind some syntactic sugar: maybe something like C#&#039;s &lt;code class=&quot;geshifilter csharp&quot;&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;using&lt;/span&gt;&lt;/code&gt;?&lt;/p&gt;

</description>
 <pubDate>Thu, 11 Oct 2007 17:00:28 -0700</pubDate>
 <dc:creator>peter_gummer</dc:creator>
 <guid isPermaLink="false">comment 357 at http://www.eiffelroom.com</guid>
</item>
<item>
 <title>No try/catch/finally for me</title>
 <link>http://www.eiffelroom.com/blog/manus_eiffel/profiling#comment-355</link>
 <description>&lt;p&gt;I don&#039;t care for any of this try (totally redundant noise word)/catch (rescue seems a better word to me)/finally. I didn&#039;t think Peter&#039;s example looked any more readable - less if anything. Colin Adams&lt;/p&gt;

</description>
 <pubDate>Tue, 09 Oct 2007 12:15:59 -0700</pubDate>
 <dc:creator>colin-adams</dc:creator>
 <guid isPermaLink="false">comment 355 at http://www.eiffelroom.com</guid>
</item>
<item>
 <title>I&#039;ve already heard this...</title>
 <link>http://www.eiffelroom.com/blog/manus_eiffel/profiling#comment-354</link>
 <description>&lt;p&gt;It would be interesting to have an idea of whom in the Eiffel community favor the existing solution over the more traditional try-catch-finally. Note that you can get the required behavior through inline agents when it is a matter of scoping a few instructions with a rescue clause (agreed it looks a little bit heavy).&lt;/p&gt;

</description>
 <pubDate>Tue, 09 Oct 2007 10:00:00 -0700</pubDate>
 <dc:creator>manus_eiffel</dc:creator>
 <guid isPermaLink="false">comment 354 at http://www.eiffelroom.com</guid>
</item>
<item>
 <title>The agent solution would</title>
 <link>http://www.eiffelroom.com/blog/manus_eiffel/profiling#comment-353</link>
 <description>&lt;p&gt;The agent solution would definitely simplify the code by hiding the rescue clause from the user. I&#039;ve added something similar for MEMORY in 6.1, the name of the new routine is called `execute_without_collection&#039;. In PROFILING_SETTINGS, we could have `execute_without_profiling&#039;.&lt;/p&gt;

</description>
 <pubDate>Tue, 09 Oct 2007 09:58:01 -0700</pubDate>
 <dc:creator>manus_eiffel</dc:creator>
 <guid isPermaLink="false">comment 353 at http://www.eiffelroom.com</guid>
</item>
<item>
 <title>Two Things...</title>
 <link>http://www.eiffelroom.com/blog/manus_eiffel/profiling#comment-351</link>
 <description>&lt;p&gt;You should add a shared class &lt;code class=&quot;geshifilter eiffel&quot;&gt;SHARED_PROFILING_SETTINGS&lt;/code&gt; providing single instance access to the settings.&lt;/p&gt;

&lt;p&gt;Second, it would be nice to have a single routine that starts/stops the profiler, which a client can pass an agent to. The agent is always executed when the profiler polling is suspended.&lt;/p&gt;

</description>
 <pubDate>Tue, 09 Oct 2007 09:10:16 -0700</pubDate>
 <dc:creator>paulbates</dc:creator>
 <guid isPermaLink="false">comment 351 at http://www.eiffelroom.com</guid>
</item>
<item>
 <title>It would look a lot less complicated if Eiffel had try..finally!</title>
 <link>http://www.eiffelroom.com/blog/manus_eiffel/profiling#comment-345</link>
 <description>&lt;p&gt;&lt;div class=&quot;geshifilter eiffel&quot; style=&quot;font-family: monospace;&quot;&gt;f &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;is&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;local&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_prof_setting: &lt;a href=&quot;http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fdocs.eiffel.com%2Feiffelstudio%2Flibraries+PROFILING_SETTING&amp;btnI=I%27m+Feeling+Lucky&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;PROFILING_SETTING&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_is_profiling: &lt;a href=&quot;http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fdocs.eiffel.com%2Feiffelstudio%2Flibraries+BOOLEAN&amp;btnI=I%27m+Feeling+Lucky&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;BOOLEAN&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;do&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;create&lt;/span&gt; l_prof_setting.&lt;span style=&quot;color: #000060;&quot;&gt;make&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- WARNING! THIS IS NOT EIFFEL!&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_is_profiling := l_prof_setting.&lt;span style=&quot;color: #000060;&quot;&gt;is_profiling&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_prof_setting.&lt;span style=&quot;color: #000060;&quot;&gt;stop_profiling&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Your code here&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000060;&quot;&gt;finally&lt;/span&gt; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- WARNING! THIS IS NOT EIFFEL!&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;if&lt;/span&gt; l_is_profiling &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;then&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_prof_setting.&lt;span style=&quot;color: #000060;&quot;&gt;start_profiling&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;

</description>
 <pubDate>Sat, 06 Oct 2007 17:25:50 -0700</pubDate>
 <dc:creator>peter_gummer</dc:creator>
 <guid isPermaLink="false">comment 345 at http://www.eiffelroom.com</guid>
</item>
<item>
 <title>Profiling</title>
 <link>http://www.eiffelroom.com/blog/manus_eiffel/profiling</link>
 <description>&lt;p&gt;When you have a performance problem, profiling an application will help you figure out where the bottleneck is. However, most profiling tool have a tendency to slow down the execution by a significant factor and EiffelStudio is unfortunately no different. Nevertheless, we have added a neat class called &lt;code class=&quot;geshifilter eiffel&quot;&gt;&lt;a href=&quot;http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fdocs.eiffel.com%2Feiffelstudio%2Flibraries+PROFILING_SETTING&amp;btnI=I%27m+Feeling+Lucky&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;PROFILING_SETTING&lt;/span&gt;&lt;/a&gt;&lt;/code&gt; that will enable you to enable/disable the profiler on only some parts of an execution.&lt;/p&gt;

&lt;p&gt;To make sure you are using this class properly you should know the following: &lt;ul&gt;
    &lt;li&gt; Profiling should be enabled in the project settings&lt;/li&gt;
    &lt;li&gt; First executed instruction should be a call to &lt;code class=&quot;geshifilter eiffel&quot;&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fdocs.eiffel.com%2Feiffelstudio%2Flibraries+PROFILING_SETTING&amp;btnI=I%27m+Feeling+Lucky&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;PROFILING_SETTING&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#125;&lt;/span&gt;.&lt;span style=&quot;color: #000060;&quot;&gt;stop_profiling&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt; Last executed instruction should be a call to &lt;code class=&quot;geshifilter eiffel&quot;&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fdocs.eiffel.com%2Feiffelstudio%2Flibraries+PROFILING_SETTING&amp;btnI=I%27m+Feeling+Lucky&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;PROFILING_SETTING&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;#125;&lt;/span&gt;.&lt;span style=&quot;color: #000060;&quot;&gt;start_profiling&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt; When profiling a section of code the calls &lt;code class=&quot;geshifilter eiffel&quot;&gt;start_profiling&lt;/code&gt; and &lt;code class=&quot;geshifilter eiffel&quot;&gt;stop_profiling&lt;/code&gt;, they should appear in the same routine, as otherwise the profiler will be confused&lt;/li&gt;
&lt;/ul&gt;

&lt;/p&gt;

&lt;p&gt;With EiffelStudio 6.0, there is also a very handy feature that comes for free with the new project settings structure with libraries. By default libraries do not inherit the `profiling&#039; setting and are therefore excluded from the profiling (thus speeding up the profiling). It simply means that you won&#039;t know how much time is spent in a routine from a library, but the time is still accounted for the callers of that routine. If you want to profile a library, you simply need to mark it so in your project configuration.&lt;/p&gt;

&lt;p&gt;I&#039;ve showed that you can profile a certain portion of code, but you can also disable profiling a certain portion too. We use it when profiling the compiler for not tracking the time spent in the parser. Here is an example:&lt;/p&gt;

&lt;p&gt;&lt;div class=&quot;geshifilter eiffel&quot; style=&quot;font-family: monospace;&quot;&gt;f &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;is&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;local&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_prof_setting: &lt;a href=&quot;http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fdocs.eiffel.com%2Feiffelstudio%2Flibraries+PROFILING_SETTING&amp;btnI=I%27m+Feeling+Lucky&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;PROFILING_SETTING&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_is_profiling: &lt;a href=&quot;http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fdocs.eiffel.com%2Feiffelstudio%2Flibraries+BOOLEAN&amp;btnI=I%27m+Feeling+Lucky&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;BOOLEAN&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; retried: &lt;a href=&quot;http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fdocs.eiffel.com%2Feiffelstudio%2Flibraries+BOOLEAN&amp;btnI=I%27m+Feeling+Lucky&quot;&gt;&lt;span style=&quot;color: #800000&quot;&gt;BOOLEAN&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;do&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;not&lt;/span&gt; retried &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;then&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;create&lt;/span&gt; l_prof_setting.&lt;span style=&quot;color: #000060;&quot;&gt;make&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_is_profiling := l_prof_setting.&lt;span style=&quot;color: #000060;&quot;&gt;is_profiling&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_prof_setting.&lt;span style=&quot;color: #000060;&quot;&gt;stop_profiling&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008000; font-style: italic;&quot;&gt;-- Your code here&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;if&lt;/span&gt; l_is_profiling &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;then&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;check&lt;/span&gt; l_prof_setting_not_void: l_prof_setting /= &lt;span style=&quot;color: #800080;&quot;&gt;Void&lt;/span&gt; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l_prof_setting.&lt;span style=&quot;color: #000060;&quot;&gt;start_profiling&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;rescue&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; retried := &lt;span style=&quot;color: #800080;&quot;&gt;True&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;retry&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF; font-weight: bold;&quot;&gt;end&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;Ok, it looks a little bit more complicated than what you expected. If you do not care about correctness then you know that you can remove: &lt;ul&gt;
    &lt;li&gt; the rescue clause if you do not anticipate exceptions&lt;/li&gt;
    &lt;li&gt; the `l_is_profiling&#039; local variable if nothing else is enabling/disabling the profiler&lt;/li&gt;
&lt;/ul&gt;

&lt;/p&gt;

&lt;p&gt;Enjoy Eiffel and profiling!&lt;/p&gt;

</description>
 <comments>http://www.eiffelroom.com/blog/manus_eiffel/profiling#comments</comments>
 <category domain="http://www.eiffelroom.com/tag/eiffelstudio">EiffelStudio</category>
 <category domain="http://www.eiffelroom.com/tag/profile">profile</category>
 <pubDate>Fri, 05 Oct 2007 09:58:28 -0700</pubDate>
 <dc:creator>manus_eiffel</dc:creator>
 <guid isPermaLink="false">225 at http://www.eiffelroom.com</guid>
</item>
</channel>
</rss>
