Make that last line call compile and see if it helps. When the Silverlight integration was written that gave a 4x speedup when using top-level functions/variables:
source.Compile().Execute(mainScope); Not sure if that's the case anymore, but it's worth a try. ~js From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ronnie Maor Sent: Saturday, September 27, 2008 11:22 PM To: Discussion of IronPython Subject: [IronPython] IPyb5 performance Hi all, I've finally managed to get my code running correctly under IPy2b5 - thanks everyone who helped! I'm now left with a performance problem. My code seems to run roughly 2 times slower: * infra tests regressed from 19 seconds in IPy 1.1.1 to 33 seconds in IPy2b5 * application level tests regressed from 375 seconds in 1.1.1 to 705 seconds in IPy2b5 (these are single measurements, but variance is not too big - about 5%) startup time is also much longer, but I can live with that. before trying to pinpoint the bottlenecks, I wanted to check I'm not missing something stupid, like turning on optimizations in the DLR... below is the hosting code I'm using to run the tests. I tried with and without "Debug" flag, and it doesn't seem to change anything (except debug allows me to understand the stack traces). I can also run the infra tests with ipy directly, which showed that -O and -OO don't help either. Is there something else I should be doing? any tips? thanks! // set up runtime and engine Dictionary<string, object> runtimeOptions = new Dictionary<string, object>(); runtimeOptions["Debug"] = true; ScriptRuntime runtime = IronPython.Hosting.Python.CreateRuntime(runtimeOptions); runtime.LoadAssembly(typeof(String).Assembly); // Add reference to System runtime.LoadAssembly(typeof(Uri).Assembly); // Add reference to mscorlib engine = runtime.GetEngine("Python"); .... // run file as __main__ engine.SetSearchPaths(new string[] {".", progdir, backend_dir, stdlib_dir}); List argv = new List(); argv.append(filename); for (int i = 2; i < args.Length; ++i) argv.append(args[i]); engine.GetSysModule().SetVariable("argv", argv); mainScope = engine.CreateScope(); mainScope.SetVariable("__name__", "__main__"); var main_module = Microsoft.Scripting.Hosting.Providers.HostingHelpers.GetScope(mainScope); runtime.Globals.SetVariable("__main__", main_module); mainScope.SetVariable("__file__",filename); ScriptSource source = engine.CreateScriptSourceFromFile(filename, Encoding.Default, SourceCodeKind.Statements); source.Execute(mainScope);
_______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com