set_time_limit_004.phpt 863 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. Test V8::setTimeLimit() : Time limit can be prolonged
  3. --SKIPIF--
  4. <?php
  5. require_once(dirname(__FILE__) . '/skipif.inc');
  6. if (getenv("SKIP_SLOW_TESTS")) {
  7. die("skip slow test");
  8. }
  9. ?>
  10. --FILE--
  11. <?php
  12. $JS = <<< EOT
  13. var text = "abcdefghijklmnopqrstuvwyxz0123456789";
  14. /* Spend 75 * >10ms in the loop, i.e. at least 750ms; hence
  15. * it should be killed if prolonging doesn't work. */
  16. for (var j = 0; j < 30; ++j) {
  17. PHP.prolongTimeLimit();
  18. var start = (new Date()).getTime();
  19. var encoded = encodeURI(text);
  20. while ((new Date()).getTime() - start < 10) {
  21. /* pass about 10ms in the loop, then prolong */
  22. var encoded = encodeURI(text);
  23. }
  24. }
  25. EOT;
  26. $v8 = new V8Js();
  27. $v8->setTimeLimit(300);
  28. $v8->prolongTimeLimit = function() use ($v8) {
  29. $v8->setTimeLimit(300);
  30. };
  31. $v8->executeString($JS);
  32. ?>
  33. ===EOF===
  34. --EXPECTF--
  35. ===EOF===