From 10 to 1 (and less)

Our first exploration of PHP calls for XAPI was based on a lib, named PHP-xenapi (btw, thanks to Andy Goodwin for that piece of code). The "small" problem with this lib, is its slowness. I mean really slower than acceptable for us. Let's see with a small portion of code listing only "real VM" (no templates or xen dom0):

$ time php example.php
VM3
VM1
VM2

real    0m10.103s
user    0m0.360s
sys    0m0.148s

Ok, 10 secs for that. Wireshark tells us than approx. 2500 packets were exchanged during the process. When we look at the code, we saw that lib recreate a entire connection each time. After a patch Let's factorize connections and don't recreate them if they already exist. Corrections are available on my personal github page. Does it change something?

$ time php example.php
VM3
VM1
VM2

real    0m0.796s
user    0m0.120s
sys    0m0.016s

Much better: from 10 to <1 sec! Wireshark tells us 285 packets were transfered during the same operation. Now it's more acceptable ;)