[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bindings
Subject:    Re: [Kde-bindings] playground/bindings/kimono
From:       Richard Dale <rdale () foton ! es>
Date:       2007-03-21 10:36:13
Message-ID: 200703211036.14099.rdale () foton ! es
[Download RAW message or body]

On Tuesday 20 March 2007, Arno Rehn wrote:
> SVN commit 644738 by arnorehn:
>
> * Made instance operators work
OK good this is quite simple to implement. I wasn't sure that checking for 
operator methods with one arg was a good way of telling if it was an instance 
method, but it seems there aren't really any static ones with one arg and it 
does work:

rbqtapi -roperator | grep static |grep -v ','
        static const QPoint QGlobalSpace::operator-(const QPoint&)
        static const QPointF QGlobalSpace::operator-(const QPointF&)

But when I ran my 'performance test' which consists of starting tutorial t14, 
setting the force to 40 and firing a shot while watching the cpu consumption 
with top, I noticed it uses quite a bit more with this change. Up to 38% of 
cpu from about 22% before. I changed the code to set a boolean to save the 
value of the test to avoid doing it twice per method call. Then I tried 
duplicating the IsInstanceOperator call so it was tested 5 times and found 
that t14 ran with about twice the cpu load as with no calls at all. So it 
looks like there is quite a big overhead per method call.

I think it would be quicker and easier to special case these methods on the 
C/C++ side. Then we would probably only need to do a string comparison on the 
method name, and rearranging the smoke stack is easier there too.

-- Richard


["is_operator.patch" (text/x-diff)]

Index: SmokeInvocation.cs
===================================================================
--- SmokeInvocation.cs	(revision 644885)
+++ SmokeInvocation.cs	(working copy)
@@ -397,9 +397,10 @@
 			}
 			
 			StackItem[] stack = new StackItem[callMessage.ArgCount+1];
-
+			bool instanceOperator = false;
 			if (callMessage.MethodSignature != null) {
-				if (Qyoto.IsInstanceOperator((MethodInfo) callMessage.MethodBase)) {
+				instanceOperator = Qyoto.IsInstanceOperator((MethodInfo) callMessage.MethodBase);
+				if (instanceOperator) {
 					// for instance operators only length of 2 => 1. return type, 2. value to compare
 					stack = new StackItem[2];
 					// TODO: is it sometimes a primitive value to compare?
@@ -444,7 +445,7 @@
 			}
 
 			GCHandle instanceHandle;
-			if (Qyoto.IsInstanceOperator((MethodInfo) callMessage.MethodBase)) {
+			if (instanceOperator) {
 				// if it's an instance operator, the instance is the first argument
 				instanceHandle = GCHandle.Alloc(callMessage.Args[0]);
 			} else {


_______________________________________________
Kde-bindings mailing list
Kde-bindings@kde.org
https://mail.kde.org/mailman/listinfo/kde-bindings


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic