Skip to content

Commit 2e45300

Browse files
committed
Improve timelimit test to always take up 2 seconds time
1 parent 8830fc5 commit 2e45300

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/time_limit.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ if (getenv("SKIP_SLOW_TESTS")) {
1212
<?php
1313

1414
$JS = <<< EOT
15+
var start = Date.now();
1516
var text = "abcdefghijklmnopqrstuvwyxz0123456789";
16-
for (var i = 0; i < 20000000; ++i) {
17+
while (true) {
18+
if (Date.now() - start > 2000) { // 2 seconds safety valve
19+
break;
20+
}
1721
var encoded = encodeURI(text);
1822
}
1923
EOT;

0 commit comments

Comments
 (0)