Changeset 42 for trunk/ext/php
- Timestamp:
- 03/19/2003 19:06:55 (6 years ago)
- Location:
- trunk/ext/php
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/php/phpext.c
r23 r42 143 143 { 144 144 case syck_str_kind: 145 ZVAL_STRINGL(o, n->data.str->ptr, n->data.str->len, 1); 145 if ( n->type_id == NULL || strcmp( n->type_id, "str" ) == 0 ) 146 { 147 ZVAL_STRINGL( o, n->data.str->ptr, n->data.str->len, 1); 148 } 149 else if ( strcmp( n->type_id, "null" ) == 0 ) 150 { 151 ZVAL_NULL( o ); 152 } 153 else if ( strcmp( n->type_id, "bool#yes" ) == 0 ) 154 { 155 ZVAL_BOOL( o, 1 ); 156 } 157 else if ( strcmp( n->type_id, "bool#no" ) == 0 ) 158 { 159 ZVAL_BOOL( o, 0 ); 160 } 161 else if ( strcmp( n->type_id, "int#hex" ) == 0 ) 162 { 163 long intVal = strtol( n->data.str->ptr, NULL, 16 ); 164 ZVAL_LONG( o, intVal ); 165 } 166 else if ( strcmp( n->type_id, "int#oct" ) == 0 ) 167 { 168 long intVal = strtol( n->data.str->ptr, NULL, 8 ); 169 ZVAL_LONG( o, intVal ); 170 } 171 else if ( strcmp( n->type_id, "int" ) == 0 ) 172 { 173 long intVal = strtol( n->data.str->ptr, NULL, 10 ); 174 ZVAL_LONG( o, intVal ); 175 } 176 else if ( strcmp( n->type_id, "float" ) == 0 ) 177 { 178 //double floatVal = strtol( n->data.str->ptr ); 179 ZVAL_DOUBLE( o, 3.45 ); 180 } 181 else 182 { 183 ZVAL_STRINGL(o, n->data.str->ptr, n->data.str->len, 1); 184 } 146 185 break; 147 186 … … 193 232 syck_parser_str( parser, arg, arg_len, NULL ); 194 233 syck_parser_handler( parser, php_syck_handler ); 234 syck_parser_implicit_typing( parser, 1 ); 235 syck_parser_taguri_expansion( parser, 0 ); 195 236 v = syck_parse( parser ); 196 237 syck_lookup_sym( parser, v, &obj ); -
trunk/ext/php/syck.php
r23 r42 10 10 } 11 11 echo "<br>\n"; 12 echo "Testing load: "; 13 print_r( syck_load( "{test: &anc {and: 2}, or: {alias: *anc}}" ) ); 12 echo "Testing load: \n"; 13 $doc =<<<YAML 14 - 15 a: 1 16 b: 2 17 c: 3 18 d: TRUE 19 e: ~ 20 f: test_me 21 g: 22 test: also 23 h: 0xFF 24 i: 012 25 YAML; 26 27 $iter = 10000; 28 29 echo "DOC #1 = $iter x " . strlen( $doc ) . "\n"; 30 $syck_start = microtime(); 31 foreach( range( 0, $iter ) as $i ) 32 { 33 $test_obj = syck_load( $doc ); 34 } 35 $syck_stop = microtime(); 36 37 $test_str = serialize( $test_obj ); 38 $unser_start = microtime(); 39 foreach( range( 0, $iter ) as $i ) 40 { 41 $test_obj = unserialize( $test_str ); 42 } 43 $unser_stop = microtime(); 44 45 $doc2 = ""; 46 foreach( range( 0, $iter ) as $i ) 47 { 48 $doc2 .= $doc . "\n"; 49 } 50 echo "DOC #2 = 1 x " . strlen( $doc2 ) . "\n"; 51 $syck2_start = microtime(); 52 $test_obj = syck_load( $doc2 ); 53 $syck2_stop = microtime(); 54 55 $test_str = serialize( $test_obj ); 56 $unser2_start = microtime(); 57 $test_obj = unserialize( $test_str ); 58 $unser2_stop = microtime(); 59 60 61 function elapsed( $start, $stop ) 62 { 63 $start_mt = explode( " ", $start ); 64 $stop_mt = explode( " ", $stop ); 65 $start_total = doubleval( $start_mt[0] ) + $start_mt[1]; 66 $stop_total = doubleval( $stop_mt[0] ) + $stop_mt[1]; 67 return sprintf( "%0.6f", $stop_total - $start_total ); 68 } 69 70 echo "syck: " . elapsed( $syck_start, $syck_stop ) . " " . elapsed( $syck2_start, $syck2_stop ) . "\n"; 71 echo "php: " . elapsed( $unser_start, $unser_stop ) . " " . elapsed( $unser2_start, $unser2_stop ) . "\n"; 72 14 73 ?>