|
| 1 | +--TEST-- |
| 2 | +Parse URL |
| 3 | +--EXTENSIONS-- |
| 4 | +uri |
| 5 | +--FILE-- |
| 6 | +<?php |
| 7 | + |
| 8 | +$t1 = hrtime(true); |
| 9 | +for ($i = 0; $i < 1000; $i++) { |
| 10 | + Uri\ Rfc3986\Uri:: parse( "https://username:[email protected]:8080/pathname1/pathname2/pathname3?query=true#hash-exists"); |
| 11 | +} |
| 12 | +$t2 = hrtime(true); |
| 13 | + |
| 14 | +$t3 = hrtime(true); |
| 15 | +for ($i = 0; $i < 1000; $i++) { |
| 16 | + Uri\ WhatWg\Url:: parse( "https://username:[email protected]:8080/pathname1/pathname2/pathname3?query=true#hash-exists"); |
| 17 | +} |
| 18 | +$t4 = hrtime(true); |
| 19 | + |
| 20 | +$t5 = hrtime(true); |
| 21 | +for ($i = 0; $i < 1000; $i++) { |
| 22 | + parse_url( "https://username:[email protected]:8080/pathname1/pathname2/pathname3?query=true#hash-exists"); |
| 23 | +} |
| 24 | +$t6 = hrtime(true); |
| 25 | + |
| 26 | +echo "RFC 3986 parser:\n"; |
| 27 | +var_dump(($t2 - $t1) / 1_000_000_000); |
| 28 | +var_dump( Uri\ Rfc3986\Uri:: parse( "https://username:[email protected]:8080/pathname1/pathname2/pathname3?query=true#hash-exists")); |
| 29 | +echo "------------------------\n"; |
| 30 | + |
| 31 | +echo "WHATWG parser:\n"; |
| 32 | +var_dump(($t4 - $t3) / 1_000_000_000); |
| 33 | +var_dump( Uri\ WhatWg\Url:: parse( "https://username:[email protected]:8080/pathname1/pathname2/pathname3?query=true#hash-exists")); |
| 34 | +echo "------------------------\n"; |
| 35 | + |
| 36 | +echo "parse_url:\n"; |
| 37 | +var_dump(($t6 - $t5) / 1_000_000_000); |
| 38 | +var_dump( parse_url( "https://username:[email protected]:8080/pathname1/pathname2/pathname3?query=true#hash-exists")); |
| 39 | +echo "------------------------\n"; |
| 40 | + |
| 41 | +?> |
| 42 | +--EXPECTF-- |
| 43 | +RFC 3986 parser: |
| 44 | +float(0.004389959) |
| 45 | +object(Uri\Rfc3986\Uri)#%d (%d) { |
| 46 | + ["scheme"]=> |
| 47 | + string(5) "https" |
| 48 | + ["userinfo"]=> |
| 49 | + string(17) "username:password" |
| 50 | + ["username"]=> |
| 51 | + string(8) "username" |
| 52 | + ["password"]=> |
| 53 | + string(8) "password" |
| 54 | + ["host"]=> |
| 55 | + string(14) "www.google.com" |
| 56 | + ["port"]=> |
| 57 | + int(8080) |
| 58 | + ["path"]=> |
| 59 | + string(30) "/pathname1/pathname2/pathname3" |
| 60 | + ["query"]=> |
| 61 | + string(10) "query=true" |
| 62 | + ["fragment"]=> |
| 63 | + string(11) "hash-exists" |
| 64 | +} |
| 65 | +------------------------ |
| 66 | +WHATWG parser: |
| 67 | +float(0.007400166) |
| 68 | +object(Uri\WhatWg\Url)#%d (%d) { |
| 69 | + ["scheme"]=> |
| 70 | + string(5) "https" |
| 71 | + ["username"]=> |
| 72 | + string(8) "username" |
| 73 | + ["password"]=> |
| 74 | + string(8) "password" |
| 75 | + ["host"]=> |
| 76 | + string(14) "www.google.com" |
| 77 | + ["port"]=> |
| 78 | + int(8080) |
| 79 | + ["path"]=> |
| 80 | + string(30) "/pathname1/pathname2/pathname3" |
| 81 | + ["query"]=> |
| 82 | + string(10) "query=true" |
| 83 | + ["fragment"]=> |
| 84 | + string(11) "hash-exists" |
| 85 | +} |
| 86 | +------------------------ |
| 87 | +parse_url: |
| 88 | +float(0.007400166) |
| 89 | +array(%d) { |
| 90 | + ["scheme"]=> |
| 91 | + string(5) "https" |
| 92 | + ["host"]=> |
| 93 | + string(14) "www.google.com" |
| 94 | + ["port"]=> |
| 95 | + int(8080) |
| 96 | + ["user"]=> |
| 97 | + string(8) "username" |
| 98 | + ["pass"]=> |
| 99 | + string(8) "password" |
| 100 | + ["path"]=> |
| 101 | + string(30) "/pathname1/pathname2/pathname3" |
| 102 | + ["query"]=> |
| 103 | + string(10) "query=true" |
| 104 | + ["fragment"]=> |
| 105 | + string(11) "hash-exists" |
| 106 | +} |
| 107 | +------------------------ |
0 commit comments