From: Jost B. <jos...@ya...> - 2005-01-14 11:18:26
|
[Please excuse the delay] > I"ve noticed that creating objects take much more time comparing to Java The jni/reflection/net overhead is currently somewhere between 2 .. 3.5. That means that PHP needs 2 (GNU) up to 3.5 (SUN) as much time to create a proxy through JNI. script1: [1 * CreateInstance + 1 * Invoke -> 0.0790050029755 sec] script2: [1 * PHP print + 4 * CreateInstance -> 0.458841085434 sec] I am not sure if your test is relevant. The PHP IO operation in script2 probably takes the most of the time. Both scripts probably include the times for the server connect sequence, which is currently quite expensive because the PHP/Java Bridge currently does not use persistent connections. So I think the above times are meaningless. Can you please run the benchmark in the tests.php5 folder and post the times? If you find that the interpreted(*) java method executes more than 2 or 3.5 times faster than the PHP method doing the same thing using JNI/Reflection calls, then we have to examine the network connection more closely: The performance also depends on the OS kernel and how fast it can push the bytes through the communication channel. Unix domain sockets are usually nearly as efficient as shared memory, but the throughput may vary from kernel to kernel; especially if your kernel is compiled with debug enabled, the delay becomes noticeable. Regards, Jost Boekemeier (*) The compiled java method is about 10 times faster than the interpreted java script. But that's normal behaviour, native machine code is always much faster than any interpreted script code. |