@ 2022-09-09T10:09:38Z <?php
// $this->last_result analogue in WPDB for 80000 posts' "SELECT meta_key, meta_value WHERE...."
$last_result = array_fill( 0, 80000, (object) [
'meta_key' => 'hello_who',
'meta_value' => str_repeat( 'World and WordPress ', 20 ),
] );
const ARRAY_N = 0b0;
$output = 0b0;
// Startup engines;
number_format( hrtime( true ) / 1e9 );
$new_array = [];
foreach ( (array) $last_result as $row ) {
// ...integer-keyed row arrays.
$new_array[] = array_values( get_object_vars( $row ) );
}
$new_array = [];
foreach ( (array) $last_result as $row ) {
// ...column name-keyed row arrays.
$new_array[] = get_object_vars( $row );
}
$new_array = [];
// Test.
$new_array = [];
$t = hrtime( true );
foreach ( (array) $last_result as $row ) {
if ( ARRAY_N === $output ) {
// ...integer-keyed row arrays.
$new_array[] = array_values( get_object_vars( $row ) );
} else {
// ...column name-keyed row arrays.
$new_array[] = get_object_vars( $row );
}
}
echo 'Old ARRAY_N: ', number_format( ( hrtime( true ) - $t ) / 1e9, 5 ).'s', "\n";
$new_array = [];
$t = hrtime( true );
if ( ARRAY_N === $output ) {
foreach ( (array) $last_result as $row ) {
// ...integer-keyed row arrays.
$new_array[] = array_values( get_object_vars( $row ) );
}
} else {
foreach ( (array) $last_result as $row ) {
// ...column name-keyed row arrays.
$new_array[] = get_object_vars( $row );
}
}
echo 'New ARRAY_N: ', number_format( ( hrtime( true ) - $t ) / 1e9, 5 ).'s', "\n";
// Test ARRAY_A now.
$output = 0b1;
$new_array = [];
$t = hrtime( true );
foreach ( (array) $last_result as $row ) {
if ( ARRAY_N === $output ) {
// ...integer-keyed row arrays.
$new_array[] = array_values( get_object_vars( $row ) );
} else {
// ...column name-keyed row arrays.
$new_array[] = get_object_vars( $row );
}
}
echo 'Old ARRAY_A: ', number_format( ( hrtime( true ) - $t ) / 1e9, 5 ).'s', "\n";
$new_array = [];
$t = hrtime( true );
if ( ARRAY_N === $output ) {
foreach ( (array) $last_result as $row ) {
// ...integer-keyed row arrays.
$new_array[] = array_values( get_object_vars( $row ) );
}
} else {
foreach ( (array) $last_result as $row ) {
// ...column name-keyed row arrays.
$new_array[] = get_object_vars( $row );
}
}
echo 'New ARRAY_A: ', number_format( ( hrtime( true ) - $t ) / 1e9, 5 ).'s', "\n";
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for git.master Old ARRAY_N: 0.00726s
New ARRAY_N: 0.00669s
Old ARRAY_A: 0.00413s
New ARRAY_A: 0.00321s
Output for git.master_jit Fatal error: Out of memory (allocated 18878464 bytes) (tried to allocate 2097160 bytes) in /in/6OOHn on line 17
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
Process exited with code 255 . Output for rfc.property-hooks Old ARRAY_N: 0.00575s
New ARRAY_N: 0.00442s
Old ARRAY_A: 0.00419s
New ARRAY_A: 0.00277s
This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches Archived branches Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:dark mode live preview
61.54 ms | 407 KiB | 5 Q