0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 23:51:51 +00:00

Merge pull request #198 from stesie/slow-down-time-limit-tests

Make set_time_limit tests slower
This commit is contained in:
Stefan Siegl 2016-01-06 17:43:45 +01:00
commit 66841e8fb6
2 changed files with 8 additions and 8 deletions

View File

@ -11,8 +11,8 @@ var jsfunc = function() {
var start = (new Date()).getTime(); var start = (new Date()).getTime();
var text = "abcdefghijklmnopqrstuvwyxz0123456789"; var text = "abcdefghijklmnopqrstuvwyxz0123456789";
while ((new Date()).getTime() - start < 500) { while ((new Date()).getTime() - start < 800) {
/* pass at least 500ms in the loop so the timer loop has plenty of /* pass at least 800ms in the loop so the timer loop has plenty of
* time to trigger. */ * time to trigger. */
var encoded = encodeURI(text); var encoded = encodeURI(text);
} }
@ -22,10 +22,10 @@ EOT;
$v8 = new V8Js(); $v8 = new V8Js();
/* Set very short time limit, but enough so v8 can start up safely. */ /* Set very short time limit, but enough so v8 can start up safely. */
$v8->setTimeLimit(100); $v8->setTimeLimit(200);
$v8->incrTimeLimit = function() use ($v8) { $v8->incrTimeLimit = function() use ($v8) {
$v8->setTimeLimit(300); $v8->setTimeLimit(500);
}; };
$func = $v8->executeString($JS); $func = $v8->executeString($JS);
@ -43,5 +43,5 @@ try {
object(V8Function)#%d (0) { object(V8Function)#%d (0) {
} }
V8JsTimeLimitException V8JsTimeLimitException
Script time limit of 300 milliseconds exceeded Script time limit of 500 milliseconds exceeded
===EOF=== ===EOF===

View File

@ -7,7 +7,7 @@ Test V8::setTimeLimit() : Time limit can be prolonged
$JS = <<< EOT $JS = <<< EOT
var text = "abcdefghijklmnopqrstuvwyxz0123456789"; var text = "abcdefghijklmnopqrstuvwyxz0123456789";
/* Spend 30 * >10ms in the loop, i.e. at least 300ms; hence /* Spend 75 * >10ms in the loop, i.e. at least 750ms; hence
* it should be killed if prolonging doesn't work. */ * it should be killed if prolonging doesn't work. */
for (var j = 0; j < 30; ++j) { for (var j = 0; j < 30; ++j) {
PHP.prolongTimeLimit(); PHP.prolongTimeLimit();
@ -22,10 +22,10 @@ for (var j = 0; j < 30; ++j) {
EOT; EOT;
$v8 = new V8Js(); $v8 = new V8Js();
$v8->setTimeLimit(100); $v8->setTimeLimit(300);
$v8->prolongTimeLimit = function() use ($v8) { $v8->prolongTimeLimit = function() use ($v8) {
$v8->setTimeLimit(100); $v8->setTimeLimit(300);
}; };
$v8->executeString($JS); $v8->executeString($JS);