Stephen Chapman wrote: > So after much research on the library . It certainly looks like the > invoke method is taking all the time. Is this because of the > conversion from Variant??? > > On Tue, Feb 7, 2017 at 11:09 AM, Stephen Chapman > <schapman1...@gmail.com <mailto:schapman1...@gmail.com>> wrote: > > Hello, > I am having a speed issue while running dll functions. I have > a minimal com server example and a minimal com client example > below. I have added cProfile to the example. All source files > and the profile are attached. > > So when I run this example I get between 1.4 seconds to 1.7 > seconds. I am running a loop of 10,000 doing 2 methods in the > loop. So the here are a couple lines from the profile. > > ncalls tottime percall cumtime percall > filename:lineno(function) > 1 0.050 0.050 1.740 1.740 > cpminimaltest.py:6(testcalltime) > 20001 0.103 0.000 1.689 0.000 dynamic.py:41(__call__) > 20004 0.698 0.000 1.247 0.000 > automation.py:702(Invoke) > 80001 0.276 0.000 0.313 0.000 > automation.py:197(_set_value) >
A late-bound COM call is not an efficient operation, and having it be out-of-process adds even more time. 20,000 calls in 0.7 seconds is 35 microseconds per call, which is pretty ding-danged fast. In my view, you have unrealistic expectations. > > It seems like the Invoke is taking an inordinate amount of time. > When I create a minimal example in C# and run the same test. I > get .009 seconds. Is there something I am not doing right. > Do you mean 0.009 seconds for 20,000 calls? I don't believe that. How are you doing the timing? Are you measuring wall-clock time or CPU time? Since it's out-of-process, time spent in the server isn't going to be counted. Are you sure the calls weren't optimized away? I suppose it is possible that C# did the dynamic COM lookup once and cached the result, but even so, I can't believe 500 nanoseconds per call with a context switch involved. In your minimal example, are BOTH ends in C#? -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32