set_time_limit_004.phpt 803 B

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