Skip to content

Poor V8Function call performance #158

@stesie

Description

@stesie

If you keep a reference to a JS function in a PHP variable (by means of a V8Function object) like so:

$v8 = new V8Js();
$func = $v8->executeString('(function() { print("Hello World\\n"); });');

for($i = 0; $i < 1000; $i ++) {
    $func();
}

... the performance is pretty bad: V8Js 0.2.1 takes 2.466s to execute these 1k calls, V8Js 0.1.5 even needs 80s.

Compared to the performance we achieve if executing the functions via executeString like

$v8 = new V8Js();
for($i = 0; $i < 1000; $i ++) {
    $v8->executeString('(function() { print("Hello World\\n"); })();');
}

... which even has the disadvantage that the function is compiled over and over again, it just takes 0.168s to run on recent V8Js and 0.247s on older ones.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions