[IronPython] Performance Issue

Wilfredo Lugo wilfredo.lugo at gmail.com
Wed Nov 12 17:31:57 CET 2008


Hi All,

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.  I have
been using this script for some time.  Right now I am working on a C#
application that also performs linear interpolation, so I decided to use
IronPython to call my script.  However, I am havving a huge performance
difference from running the script on common python and running it on
IronPython.

Here is an output of the following command using normal python (Cygwin under
windows Vista):

$ date +%M:%S;python interpolate.py;date +%M:%S
15:27
WARNING: desired starting time (Tue Jan  1 00:00:21 2008) prior to time of
first
 data point (Tue Jan  1 00:00:32 2008), current line: 9411
 series: 3D
force==False, exiting..
15:31
-----------------------------------------------------------------------------

It basically took 4 seconds to complete.  Now if I run it on IronPython
using VS and C# (Release mode) here is the output:

11/12/2008 12:16:34 PM
WARNING: desired starting time (Tue Jan 01 00:00:21 2008) prior to time of
first
 data point (Tue Jan 01 00:00:32 2008), current line: 9411
 series: 3D
force==False, exiting..
0
11/12/2008 12:19:07 PM
-----------------------------------------------------------------------------

The same script is taking more than 3 minutes and a half.

Here is the C# Code:
-----------------------------------------------------------------------------
static void Main(string[] args)
        {
            ScriptRuntime runtime = Python.CreateRuntime();
            ScriptEngine engine = Python.CreateEngine();
            ScriptSource source =
engine.CreateScriptSourceFromFile("interpolate.py");
            ScriptScope scope = engine.CreateScope();
            Console.WriteLine(DateTime.Now);
            source.Execute(scope);
            Microsoft.Func<string, string, string, string, int, int> func =
scope.GetVariable<Microsoft.Func<string, string, string, string, int,
int>>("interpolate_start");
            Console.WriteLine(func("3-day-data.txt", "3-day-output.txt",
"2008-01-01 00:00:21","2008-01-03 23:59:08",60).ToString());
            Console.WriteLine(DateTime.Now);
            Console.ReadLine();
        }

I am using IronPython 2.0B5 and Visual Studio 2003 running on .Net3.0
Windows Vista.  The script and the C# code were run on the same machine.

If there is something I am doing wrong?  I really don't understand the
performance difference.

regards,

wilfredo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20081112/4c0e718a/attachment.html>


More information about the Ironpython-users mailing list