phpv8 / v8js

V8 Javascript Engine for PHP — This PHP extension embeds the Google V8 Javascript Engine
http://pecl.php.net/package/v8js
MIT License
1.84k stars 200 forks source link

new V8Js(); very slow on windows x64 #312

Closed marsiancba closed 7 years ago

marsiancba commented 7 years ago

simple call to:

$v8 = new V8Js();

takes 400-500ms on fresh install of PHP on Windows x64. Is this normal expected behavior?

Details below: Windowx 10 x64 Builds from https://www.apachelounge.com/viewtopic.php?t=6359 (both 7.0 and 7.1 builds are slow).

Test code:

<?php
$t = microtime(true);
$v8 = new V8Js();
$t2 = microtime(true);
echo '<br>T: '.round($t2-$t,3).'<br>';
$v8->executeString("print('hello world');");
$tt = microtime(true);
echo '<br>T: '.round($tt-$t,3).'<br>';

echo '<br>v2</br>';

$t = microtime(true);
$v8 = new V8Js("PHP", [], []);
$t2 = microtime(true);
echo '<br>T: '.round($t2-$t,3).'<br>';
$v8->executeString("print('hello world');");
$tt = microtime(true);
echo '<br>T: '.round($tt-$t,3).'<br>';
?>

Output:

T: 0.46
hello world
T: 0.46

v2

T: 0.434
hello world
T: 0.434
virgofx commented 7 years ago

Can you build an older version using the exact same code to show the time differences? Also test different V8 versions as well.

marsiancba commented 7 years ago

I can not build V8js by myself, but I have checked one older build from the web:

https://github.com/maryo/php_v8js-1.2.0-7.0-vc14-x64

With this build I get times in range 50-100ms (but it had some other problem).

stesie commented 7 years ago

Seems like one of the builds is using snapshots and the other one doesn't.

stesie commented 7 years ago

No response, closing. Feel free to re-open with more information.