<br><div>Hi All,</div><div><br></div><div>I have a Python interpolation script which basically reads data from a file and perform a linear interpolation of the data present on the file. &nbsp;I have been using this script for some time. &nbsp;Right now I am working on a C# application that also performs linear interpolation, so I decided to use IronPython to call my script. &nbsp;However, I am havving a huge performance difference from running the script on common python and running it on IronPython.</div>
<div><br></div><div>Here is an output of the following command using normal python (Cygwin under windows Vista):</div><div><br></div><div><div>$ date +%M:%S;python interpolate.py;date +%M:%S</div><div>15:27</div><div>WARNING: desired starting time (Tue Jan &nbsp;1 00:00:21 2008) prior to time of first</div>
<div>&nbsp;data point (Tue Jan &nbsp;1 00:00:32 2008), current line: 9411</div><div>&nbsp;series: 3D</div><div>force==False, exiting..</div><div>15:31</div><div>-----------------------------------------------------------------------------<br>
</div><div><br></div><div>It basically took 4 seconds to complete. &nbsp;Now if I run it on IronPython using VS and C# (Release mode) here is the output:</div><div><br></div><div><div>11/12/2008 12:16:34 PM</div><div>WARNING: desired starting time (Tue Jan 01 00:00:21 2008) prior to time of first</div>
<div>&nbsp;data point (Tue Jan 01 00:00:32 2008), current line: 9411</div><div>&nbsp;series: 3D</div><div>force==False, exiting..</div><div>0</div><div>11/12/2008 12:19:07 PM</div><div>-----------------------------------------------------------------------------<br>
</div><div><br></div><div>The same script is taking more than 3 minutes and a half. &nbsp;</div><div><br></div><div>Here is the C# Code:</div><div>-----------------------------------------------------------------------------<br>
</div><div><div>static void Main(string[] args)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptRuntime runtime = Python.CreateRuntime();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptEngine engine = Python.CreateEngine();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptSource source = engine.CreateScriptSourceFromFile(&quot;interpolate.py&quot;);</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptScope scope = engine.CreateScope();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.WriteLine(DateTime.Now);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;source.Execute(scope);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Microsoft.Func&lt;string, string, string, string, int, int&gt; func = scope.GetVariable&lt;Microsoft.Func&lt;string, string, string, string, int, int&gt;&gt;(&quot;interpolate_start&quot;);</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.WriteLine(func(&quot;3-day-data.txt&quot;, &quot;3-day-output.txt&quot;, &quot;2008-01-01 00:00:21&quot;,&quot;2008-01-03 23:59:08&quot;,60).ToString());</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.WriteLine(DateTime.Now);</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.ReadLine();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>I am using IronPython 2.0B5 and Visual Studio 2003 running on .Net3.0 Windows Vista. &nbsp;The script and the C# code were run on the same machine.</div>
<div><br></div><div>If there is something I am doing wrong? &nbsp;I really don&#39;t understand the performance difference.</div><div><br></div><div>regards,</div><div><br></div><div>wilfredo</div></div></div></div>