[IronPython] Speed test

JoeSox joesox at gmail.com
Thu Apr 20 07:27:44 CEST 2006


On 4/19/06, Dino Viehland <dinov at exchange.microsoft.com> wrote:
> I've opened a bug in our internal database to track the issue.  I'm not sure when we'll get to looking at it just yet as it may be somewhat of an involved investigation.  But at least we won't forget about it.
>
> If you could give us something that was nice and self contained then we might be able to get to it sooner.
>

Ok great.  I think this will work.  Here are the two files you will need:
http://joeswammi.com/projects/CNUDB.py
http://joeswammi.com/projects/machine_All.txt

====
CNUDB.py is class ConceptNetDB with a test I added when the module is
run in Python
if __name__ == '__main__':
    c = ConceptNetDB()
    print '\n***** INITIALIZING ******'
    print '*************************\n'
    time1=time.time()
    c.load_predicates_file('E:\machine_All.txt')
    time2=time.time()
    print "-- test took",str(round(time2-time1,2)),'seconds. --\n'
====
====
machine_All.txt is a file with 631 predicate lines
====
====
Next, here is a click event I executed composed in MS Visual C# 2005
Express on an Athlon64 2.19ghz 512mb RAM laptop...
        private void button4_Click(object sender, EventArgs e)
        {
            PythonEngine ipEngine1 = new PythonEngine();
            //IronPython...
            ipEngine1.Execute("import sys");
            ipEngine1.Execute("sys.path.append('E:\')");
            ipEngine1.Execute("import CNUDB");
            ipEngine1.Execute("db=CNUDB.ConceptNetDB()");
            DateTime time1 = new DateTime();
            DateTime time2 = new DateTime();
            time1 = DateTime.Now;
            ipEngine1.Execute(@"db.load_predicates_file('E:\machine_All.txt')");
            time2 = DateTime.Now;
            MessageBox.Show(Convert.ToString(time2.Subtract(time1)));
        }
====

**** Results from MS Visual C# 2005 Express ****
ran 5 times = {.250, .078, .093, .109, .078} seconds
sum = .608
****

**** Results from IDLE 1.1.2
ran 5 times = {.03, .03, .03, .05, .03} seconds
sum = .008
****

**** Results from Wing IDE 2.1
ran 5 times = {.05, .05, .05, .05, .05} seconds
sum = .025
****

I am not sure how to run it in IronPythonConsole.exe

And a side note, if you can this example creates some interesting
objects like c.bw_edges and c.fw_edges.  I believe at one time I was
able to .GetVariable c.fw_edges into a System.Object or maybe I
couldn't because of how dynamic these objects become. For example, if
I am interpreting correctly c.bw_edges become dictionaries; the have
Keys with Lists as values.
--
Joseph



More information about the Ironpython-users mailing list