[Kde-bindings] Measuring transparent proxy performance in Qyoto

Richard Dale rdale at foton.es
Thu Mar 29 17:28:26 UTC 2007


I've been doing some experiments to see how calls via transparent proxies 
compare with ordinary method calls in Qyoto. I've hacked a version of 
QPoint.cs to try things out - please find it attached. The best approach is 
the method called 'Invoke2()', and it looks like this:

public object Invoke2(string mungedName, 
                                string signature, 
                                Type returnType, 
                                params object[] args)

The args array consists of pairs of items - the type of the arg, followed by 
the value of the arg.

testInterceptor.Invoke2("~QPoint", "()", typeof(void));
testInterceptor.Invoke2("setX$", "(int)", typeof(void), typeof(int), 5);
testInterceptor.Invoke2("QPoint$$", "(int, int)", typeof(void), typeof(int), 
xpos, typeof(int), ypos);

Because FindMethodId() needs a change to work properly with new call, the 
above calls will look like this in a completed version:

testInterceptor.Invoke2("~QPoint", "~QPoint()", typeof(void));
testInterceptor.Invoke2("setX$", "setX(int)", typeof(void), typeof(int), 5);
testInterceptor.Invoke2("QPoint$$", "QPoint(int, int)", typeof(void), 
typeof(int), xpos, typeof(int), ypos);

FindMethodId() will need to strip out the method name from the second argument 
before matching it to resolve ambiguous method calls.

This loop of constructor calls ran about 17x faster:

public static int Main(String[] args) {
    QApplication app = new QApplication(args);

    for (int i = 0; i < 1000000; i++) {
         QPoint p = new QPoint(1, 2);
    }
     return 0;
}

Proxy:
real    1m3.661s
user    1m38.262s
sys     0m7.744s

Non proxy:
real    0m7.603s
user    0m6.060s
sys     0m0.180s

This oridinary call ran about 7x faster:

public static int Main(String[] args) {
    QApplication app = new QApplication(args);

        QPoint p = new QPoint();
        for (int i = 0; i < 1000000; i++) {
            p.SetX(5);
       }
       return 0;
}

Proxy:
real    0m28.500s
user    0m28.390s
sys     0m0.092s

Non proxy:
real    0m1.403s
user    0m1.332s
sys     0m0.052s

Oh just measured it again, and it is faster than it was, and now seems more 
like 20x faster than 7x.

So transparent proxies are more expensive to construct, and about 7x slower to 
make method calls on. The second loop runs in about 2/3 the time of this 
qtruby code:

require 'Qt'

app = Qt::Application.new(ARGV)
p = Qt::Point.new()
for i in 0..1000000 do
	res = p.x
end

So i hope if this change works ok, it should make qyoto run at about the same 
speed as qtruby, which would be a lot better than it is at the moment.

-- Richard

-------------- next part --------------
A non-text attachment was scrubbed...
Name: QPoint.cs
Type: text/x-c++src
Size: 29705 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20070329/951078fe/attachment.cpp>


More information about the Kde-bindings mailing list