<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, 5) Look at the below code. It takes 7 seconds</title>
    <link>http://www.mapleprimes.com/questions/96366-5-Look-At-The-Below-Code-It-Takes-7-Seconds</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Fri, 12 Jun 2026 21:23:06 GMT</lastBuildDate>
    <pubDate>Fri, 12 Jun 2026 21:23:06 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, 5) Look at the below code. It takes 7 seconds</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, 5) Look at the below code. It takes 7 seconds</title>
      <link>http://www.mapleprimes.com/questions/96366-5-Look-At-The-Below-Code-It-Takes-7-Seconds</link>
    </image>
    <item>
      <title>The code that you've written does not execute in parallel</title>
      <link>http://www.mapleprimes.com/questions/96366-5-Look-At-The-Below-Code-It-Takes-7-Seconds?ref=Feed:MaplePrimes:5) Look at the below code. It takes 7 seconds:Comments#answer96370</link>
      <itunes:summary>&lt;p&gt;The code that you've written does not execute in parallel.&lt;/p&gt;
&lt;p&gt;According to &lt;a href='http://www.maplesoft.com/support/help/search.aspx?term=Threads[Task][Start],' target='_new'&gt;?Threads[Task][Start],&lt;/a&gt; "The Start function creates a new Task and then waits for that Task to complete before returning the value returned by the Task."&lt;/p&gt;
&lt;p&gt;Each call to Start, for example,&lt;/p&gt;
&lt;pre&gt;Threads:-Task:-Start(X1);&lt;/pre&gt;
&lt;p&gt;will run to completion before the next Task starts.&lt;/p&gt;
&lt;p&gt;So, in your code&lt;/p&gt;
&lt;pre&gt;Threads:-Task:-Start(X1);
Threads:-Task:-Start(X2);
Threads:-Task:-Start(X1);
Threads:-Task:-Start(X2);
&lt;/pre&gt;
&lt;p&gt;the tasks will run sequentially, not in parallel. The &lt;a href='http://www.maplesoft.com/support/help/search.aspx?term=Threads[Task][Start]' target='_new'&gt;?Threads[Task][Start]&lt;/a&gt; help page gives an example of how to use Start and Continue to execute tasks in parallel.&lt;/p&gt;
&lt;!--break--&gt;
&lt;p&gt;---&lt;/p&gt;
&lt;p&gt;Duncan&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;The code that you've written does not execute in parallel.&lt;/p&gt;
&lt;p&gt;According to &lt;a href='http://www.maplesoft.com/support/help/search.aspx?term=Threads[Task][Start],' target='_new'&gt;?Threads[Task][Start],&lt;/a&gt; "The Start function creates a new Task and then waits for that Task to complete before returning the value returned by the Task."&lt;/p&gt;
&lt;p&gt;Each call to Start, for example,&lt;/p&gt;
&lt;pre&gt;Threads:-Task:-Start(X1);&lt;/pre&gt;
&lt;p&gt;will run to completion before the next Task starts.&lt;/p&gt;
&lt;p&gt;So, in your code&lt;/p&gt;
&lt;pre&gt;Threads:-Task:-Start(X1);
Threads:-Task:-Start(X2);
Threads:-Task:-Start(X1);
Threads:-Task:-Start(X2);
&lt;/pre&gt;
&lt;p&gt;the tasks will run sequentially, not in parallel. The &lt;a href='http://www.maplesoft.com/support/help/search.aspx?term=Threads[Task][Start]' target='_new'&gt;?Threads[Task][Start]&lt;/a&gt; help page gives an example of how to use Start and Continue to execute tasks in parallel.&lt;/p&gt;
&lt;!--break--&gt;
&lt;p&gt;---&lt;/p&gt;
&lt;p&gt;Duncan&lt;/p&gt;</description>
      <guid>96370</guid>
      <pubDate>Thu, 26 Aug 2010 14:06:32 Z</pubDate>
      <itunes:author>DuncanA</itunes:author>
      <author>DuncanA</author>
    </item>
    <item>
      <title>Sockets does not run in parallel</title>
      <link>http://www.mapleprimes.com/questions/96366-5-Look-At-The-Below-Code-It-Takes-7-Seconds?ref=Feed:MaplePrimes:5) Look at the below code. It takes 7 seconds:Comments#answer96396</link>
      <itunes:summary>&lt;p&gt;It is worth pointing out that the most of Maple's packages, including the Sockets package, have not been verified as thread safe, therefore they may not work correctly in parallel.&amp;nbsp; Because we have not verified Sockets as thread safe and because it is implemented as an external library, Maple linearizes calls into the sockets external library.&amp;nbsp; Therefore code like this will not show a significant speed up in parallel.&lt;/p&gt;
&lt;p&gt;You can see &lt;a href="http://www.mapleprimes.com/maplesoftblog/36467-The-Current-Limitations-Of-Parallel"&gt;my post&lt;/a&gt; on the limitation of parallelism in Maple for more information.&lt;/p&gt;
&lt;p&gt;Darin&lt;/p&gt;
&lt;!--break--&gt;
&lt;p&gt;-- Kernel Developer Maplesoft&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;It is worth pointing out that the most of Maple's packages, including the Sockets package, have not been verified as thread safe, therefore they may not work correctly in parallel.&amp;nbsp; Because we have not verified Sockets as thread safe and because it is implemented as an external library, Maple linearizes calls into the sockets external library.&amp;nbsp; Therefore code like this will not show a significant speed up in parallel.&lt;/p&gt;
&lt;p&gt;You can see &lt;a href="http://www.mapleprimes.com/maplesoftblog/36467-The-Current-Limitations-Of-Parallel"&gt;my post&lt;/a&gt; on the limitation of parallelism in Maple for more information.&lt;/p&gt;
&lt;p&gt;Darin&lt;/p&gt;
&lt;!--break--&gt;
&lt;p&gt;-- Kernel Developer Maplesoft&lt;/p&gt;</description>
      <guid>96396</guid>
      <pubDate>Thu, 26 Aug 2010 22:23:31 Z</pubDate>
      <itunes:author>dohashi</itunes:author>
      <author>dohashi</author>
    </item>
    <item>
      <title>why do you use Maple for such?</title>
      <link>http://www.mapleprimes.com/questions/96366-5-Look-At-The-Below-Code-It-Takes-7-Seconds?ref=Feed:MaplePrimes:5) Look at the below code. It takes 7 seconds:Comments#answer96401</link>
      <itunes:summary>&lt;p&gt;With Excel there is 'nothing' to code (just some configuring a sheet for such a query), see its help.&lt;/p&gt;
&lt;p&gt;Exporting or processing data is a different thing, in any system I would guess.&lt;/p&gt;
&lt;p&gt;And most of the time is spent on retrieving data from the web (you have to look up some Excel sites, but I guess if you feed various sheets in a book they are done non-exclusively).&lt;/p&gt;
&lt;p&gt;&lt;a href="/view.aspx?sf=96401/280496/query_example.zip"&gt;query_example.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Edited: or better and more general one may wish to consider downloader programs like the old 'wget' (have not checked for Google) or similar writing to files, to be processed by what ever.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;With Excel there is 'nothing' to code (just some configuring a sheet for such a query), see its help.&lt;/p&gt;
&lt;p&gt;Exporting or processing data is a different thing, in any system I would guess.&lt;/p&gt;
&lt;p&gt;And most of the time is spent on retrieving data from the web (you have to look up some Excel sites, but I guess if you feed various sheets in a book they are done non-exclusively).&lt;/p&gt;
&lt;p&gt;&lt;a href="/view.aspx?sf=96401/280496/query_example.zip"&gt;query_example.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Edited: or better and more general one may wish to consider downloader programs like the old 'wget' (have not checked for Google) or similar writing to files, to be processed by what ever.&lt;/p&gt;</description>
      <guid>96401</guid>
      <pubDate>Thu, 26 Aug 2010 23:25:55 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>suggestion</title>
      <link>http://www.mapleprimes.com/questions/96366-5-Look-At-The-Below-Code-It-Takes-7-Seconds?ref=Feed:MaplePrimes:5) Look at the below code. It takes 7 seconds:Comments#answer96409</link>
      <itunes:summary>&lt;p&gt;The bottleneck is not in Maple but rather in the access to the external site. Wrap your call in CodeTools:-Usage:&lt;/p&gt;
&lt;pre&gt;CodeTools:-Usage(X1()):&lt;br&gt;memory used=275.27KiB, alloc change=0 bytes, cpu time=0.00s, real time=0.59s&lt;/pre&gt;
&lt;p&gt;The cpu time (0.00) is the Maple kernel time.&lt;/p&gt;
&lt;p&gt;While it won't help the time (it's hard to improve on 0), you can reduce the memory usage by using &lt;a href='http://www.maplesoft.com/support/help/search.aspx?term=StringTools[StringBuffer]' target='_new'&gt;?StringTools[StringBuffer]&lt;/a&gt; to catenate the lines:&lt;/p&gt;
&lt;pre&gt;X1 := proc ()&lt;br&gt;local str, sid, b, buf;&lt;br&gt;uses Sockets;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; buf := StringTools:-StringBuffer();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sid := Open("google.com", 80);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write(sid, cat("GET /finance/historical?q=INDEXSP:.INX&amp;amp;histperiod=daily HTTP/1.0 \n\n"));&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b := Read(sid);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if b = false then break; end if;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buf:-append(b);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end do;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Close(sid);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; buf:-value();&lt;br&gt;end proc:&lt;/pre&gt;
&lt;pre&gt;CodeTools:-Usage(X1()):&lt;br&gt;memory used=38.13KiB, alloc change=0 bytes, cpu time=0.00s, real time=0.56s&lt;/pre&gt;</itunes:summary>
      <description>&lt;p&gt;The bottleneck is not in Maple but rather in the access to the external site. Wrap your call in CodeTools:-Usage:&lt;/p&gt;
&lt;pre&gt;CodeTools:-Usage(X1()):&lt;br&gt;memory used=275.27KiB, alloc change=0 bytes, cpu time=0.00s, real time=0.59s&lt;/pre&gt;
&lt;p&gt;The cpu time (0.00) is the Maple kernel time.&lt;/p&gt;
&lt;p&gt;While it won't help the time (it's hard to improve on 0), you can reduce the memory usage by using &lt;a href='http://www.maplesoft.com/support/help/search.aspx?term=StringTools[StringBuffer]' target='_new'&gt;?StringTools[StringBuffer]&lt;/a&gt; to catenate the lines:&lt;/p&gt;
&lt;pre&gt;X1 := proc ()&lt;br&gt;local str, sid, b, buf;&lt;br&gt;uses Sockets;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; buf := StringTools:-StringBuffer();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sid := Open("google.com", 80);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write(sid, cat("GET /finance/historical?q=INDEXSP:.INX&amp;amp;histperiod=daily HTTP/1.0 \n\n"));&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b := Read(sid);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if b = false then break; end if;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buf:-append(b);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end do;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Close(sid);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; buf:-value();&lt;br&gt;end proc:&lt;/pre&gt;
&lt;pre&gt;CodeTools:-Usage(X1()):&lt;br&gt;memory used=38.13KiB, alloc change=0 bytes, cpu time=0.00s, real time=0.56s&lt;/pre&gt;</description>
      <guid>96409</guid>
      <pubDate>Fri, 27 Aug 2010 03:52:39 Z</pubDate>
      <itunes:author>Joe Riel</itunes:author>
      <author>Joe Riel</author>
    </item>
    <item>
      <title>@DuncanA&amp;nbsp;&amp;nbsp; ok thank you for that</title>
      <link>http://www.mapleprimes.com/questions/96366-5-Look-At-The-Below-Code-It-Takes-7-Seconds?ref=Feed:MaplePrimes:5) Look at the below code. It takes 7 seconds:Comments#comment96374</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/96348-TaskThreads-Simultaneous-Download#comment96370"&gt;@DuncanA&lt;/a&gt;&amp;nbsp;&amp;nbsp; ok thank you for that explanation.&lt;br&gt;&lt;br&gt;Could you please explain to be how I can make the above&lt;br&gt;code work in parallel ie can you provide me with a modification&lt;br&gt;of the above code &lt;strong&gt;5) &lt;/strong&gt;so it can work in parallel so I can see the speed improvment&lt;br&gt;of calling google finance in parallel instead of sequentially...&lt;br&gt;&lt;br&gt;If it is not to much to ask for could you also provide some modified code for &lt;strong&gt;4)&lt;br&gt;&lt;/strong&gt;so I can see the impovement in speed by calling X2+X3 in parallel compared to&lt;br&gt;calling X1. Since X2+X3 is called in parralel it should be much faster than X1.....&lt;strong&gt;&lt;br&gt;&lt;/strong&gt;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/96348-TaskThreads-Simultaneous-Download#comment96370"&gt;@DuncanA&lt;/a&gt;&amp;nbsp;&amp;nbsp; ok thank you for that explanation.&lt;br&gt;&lt;br&gt;Could you please explain to be how I can make the above&lt;br&gt;code work in parallel ie can you provide me with a modification&lt;br&gt;of the above code &lt;strong&gt;5) &lt;/strong&gt;so it can work in parallel so I can see the speed improvment&lt;br&gt;of calling google finance in parallel instead of sequentially...&lt;br&gt;&lt;br&gt;If it is not to much to ask for could you also provide some modified code for &lt;strong&gt;4)&lt;br&gt;&lt;/strong&gt;so I can see the impovement in speed by calling X2+X3 in parallel compared to&lt;br&gt;calling X1. Since X2+X3 is called in parralel it should be much faster than X1.....&lt;strong&gt;&lt;br&gt;&lt;/strong&gt;&lt;/p&gt;</description>
      <guid>96374</guid>
      <pubDate>Thu, 26 Aug 2010 15:08:20 Z</pubDate>
      <itunes:author>alex_01</itunes:author>
      <author>alex_01</author>
    </item>
    <item>
      <title>Importing Quotes and Counting 7s in parallel</title>
      <link>http://www.mapleprimes.com/questions/96366-5-Look-At-The-Below-Code-It-Takes-7-Seconds?ref=Feed:MaplePrimes:5) Look at the below code. It takes 7 seconds:Comments#comment96380</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/96348-TaskThreads-Simultaneous-Download#comment96374"&gt;@alex_01&lt;/a&gt;&amp;nbsp;Here are two worksheets that perform the tasks in parallel. Both use Threads not Tasks. I'm using Maple 12 which doesn't support Tasks.&lt;/p&gt;
&lt;p&gt;&lt;a href="/view.aspx?sf=96380/280454/Counting_7s_with_Thr.mw"&gt;Counting_7s_with_Thr.mw&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="/view.aspx?sf=96380/280454/Counting_7s_with_Thr.mw"&gt;&lt;/a&gt;&lt;a href="/view.aspx?sf=96380/280454/Importing_Quotes_wit.mw"&gt;Importing_Quotes_wit.mw&lt;/a&gt;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/96348-TaskThreads-Simultaneous-Download#comment96374"&gt;@alex_01&lt;/a&gt;&amp;nbsp;Here are two worksheets that perform the tasks in parallel. Both use Threads not Tasks. I'm using Maple 12 which doesn't support Tasks.&lt;/p&gt;
&lt;p&gt;&lt;a href="/view.aspx?sf=96380/280454/Counting_7s_with_Thr.mw"&gt;Counting_7s_with_Thr.mw&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="/view.aspx?sf=96380/280454/Counting_7s_with_Thr.mw"&gt;&lt;/a&gt;&lt;a href="/view.aspx?sf=96380/280454/Importing_Quotes_wit.mw"&gt;Importing_Quotes_wit.mw&lt;/a&gt;&lt;/p&gt;</description>
      <guid>96380</guid>
      <pubDate>Thu, 26 Aug 2010 16:59:07 Z</pubDate>
      <itunes:author>DuncanA</itunes:author>
      <author>DuncanA</author>
    </item>
  </channel>
</rss>