<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: built-in  function 'lines' - cost in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548929#M1563182</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tomek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This simple report shows that the inline &lt;EM&gt;lines&lt;/EM&gt; call cost's system roughly 1,6 more than using local variable. Depending on computations volume you should choose appropriate option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA tab TYPE TABLE OF string.
DATA: start TYPE i, end TYPE i, diff TYPE i.
DATA lines TYPE i.
DATA lines_n TYPE n LENGTH 4.

DO 10000 TIMES.
  APPEND 'some string' TO tab.
ENDDO.

GET RUN TIME FIELD start.
DO 10000 TIMES.
  lines_n = LINES( tab ).
*  WRITE lines_n.
ENDDO.
GET RUN TIME FIELD end.

diff = end - start.
WRITE: / 'First run', diff.

CLEAR: diff, end, start.


GET RUN TIME FIELD start.
lines = LINES( tab ).
DO 9999 TIMES.
  lines_n = lines.
*  WRITE lines_n.
ENDDO.
GET RUN TIME FIELD end.

diff = end - start.
WRITE: / 'Second run', diff.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Jan 2011 14:01:38 GMT</pubDate>
    <dc:creator>MarcinPciak</dc:creator>
    <dc:date>2011-01-18T14:01:38Z</dc:date>
    <item>
      <title>built-in  function 'lines' - cost</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548926#M1563179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know the internals or the cost of the built-in function 'lines'?&lt;/P&gt;&lt;P&gt;I'm wondering if it just returns readily available value or has to do some computations on underlying data structures.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason I'm asking is that I want to use the return value of 'lines' more than once and I'm not sure if it makes sense to store it into local variable or just use it inline.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF lines( itab) = xxx.

elseif lines(itab) === yyy.

else.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In other languages there are usually some properties on the array objects which can be directly used without any overhead. Is it the same here?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jan 2011 10:08:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548926#M1563179</guid>
      <dc:creator>former_member182670</dc:creator>
      <dc:date>2011-01-18T10:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: built-in  function 'lines' - cost</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548927#M1563180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tomek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    when you need to compute lines use 'Describe table itab into var1.'&lt;/P&gt;&lt;P&gt;and than use var1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Hardik PArikh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jan 2011 11:34:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548927#M1563180</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-18T11:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: built-in  function 'lines' - cost</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548928#M1563181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'lines' is a replacement for DESCRIBE... which can be used directly in the expressions.&lt;/P&gt;&lt;P&gt;Why you suggest is what I want to avoid. I was just wondering if it has any impact.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jan 2011 13:23:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548928#M1563181</guid>
      <dc:creator>former_member182670</dc:creator>
      <dc:date>2011-01-18T13:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: built-in  function 'lines' - cost</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548929#M1563182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tomek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This simple report shows that the inline &lt;EM&gt;lines&lt;/EM&gt; call cost's system roughly 1,6 more than using local variable. Depending on computations volume you should choose appropriate option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA tab TYPE TABLE OF string.
DATA: start TYPE i, end TYPE i, diff TYPE i.
DATA lines TYPE i.
DATA lines_n TYPE n LENGTH 4.

DO 10000 TIMES.
  APPEND 'some string' TO tab.
ENDDO.

GET RUN TIME FIELD start.
DO 10000 TIMES.
  lines_n = LINES( tab ).
*  WRITE lines_n.
ENDDO.
GET RUN TIME FIELD end.

diff = end - start.
WRITE: / 'First run', diff.

CLEAR: diff, end, start.


GET RUN TIME FIELD start.
lines = LINES( tab ).
DO 9999 TIMES.
  lines_n = lines.
*  WRITE lines_n.
ENDDO.
GET RUN TIME FIELD end.

diff = end - start.
WRITE: / 'Second run', diff.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jan 2011 14:01:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548929#M1563182</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2011-01-18T14:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: built-in  function 'lines' - cost</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548930#M1563183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I checked also other table type (sorted, standard) and results are pretty much the same.&lt;/P&gt;&lt;P&gt;So it seems that this value is read directly but there must be a small overhead related to calling a function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think there is an observable difference if I call it twice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tomek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jan 2011 14:23:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548930#M1563183</guid>
      <dc:creator>former_member182670</dc:creator>
      <dc:date>2011-01-18T14:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: built-in  function 'lines' - cost</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548931#M1563184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; call cost's system roughly 1,6 more than using local variable&lt;/P&gt;&lt;P&gt;1.6 times what?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are we not talking about microseconds, then you should be careful with the get runtime.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jan 2011 14:25:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548931#M1563184</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-18T14:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: built-in  function 'lines' - cost</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548932#M1563185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I meant first option is slower 1.6 &lt;STRONG&gt;times&lt;/STRONG&gt; then the second one. The measurement was made in microseconds but I just counted the ratio.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jan 2011 15:58:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548932#M1563185</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2011-01-18T15:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: built-in  function 'lines' - cost</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548933#M1563186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the first measurement is always slower.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.6 times 1 microsecond(measured) is irrelevant!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jan 2011 17:04:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548933#M1563186</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-01-18T17:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: built-in  function 'lines' - cost</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548934#M1563187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just to clarify. I made mistake. The first measurement using &lt;EM&gt;lines&lt;/EM&gt; over local var. access is &lt;STRONG&gt;faster&lt;/STRONG&gt; , even I repeated the testing like &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 measurement - LINES( ).&lt;/P&gt;&lt;P&gt;2 measurement - local var.&lt;/P&gt;&lt;P&gt;3 measurement - LINES( ).&lt;/P&gt;&lt;P&gt;4 measurement - loc.var&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The results were preety much the same. The time was like 30, 46 miliseconds (using 100K loop) so I think it is measurable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the system is probably handling better with built-in functions passed to kernel than addressing local var.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jan 2011 17:39:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/built-in-function-lines-cost/m-p/7548934#M1563187</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2011-01-18T17:39:16Z</dc:date>
    </item>
  </channel>
</rss>

