Add development helper to measure performance in microseconds

This commit is contained in:
Tetrakern 2024-10-27 16:03:44 +01:00
parent f387230e1c
commit 9dc916db79

View File

@ -1,5 +1,38 @@
<?php <?php
// =============================================================================
// PERFORMANCE MEASUREMENT
// =============================================================================
/**
* Stored current microtime globally
*
* @since 5.26.0
*/
function fictioneer_start_micro_time() {
global $fictioneer_start_time;
$fictioneer_start_time = microtime( 1 );
}
/**
* Writes elapses microtime to log
*
* @since 5.26.0
*/
function fictioneer_log_micro_time( $context = '' ) {
global $fictioneer_start_time;
if ( $fictioneer_start_time ) {
$prefix = $context ? "({$context}) Duration: " : 'Duration: ';
error_log( $prefix . ( microtime( 1 ) - $fictioneer_start_time ) );
}
$fictioneer_start_time = null;
}
// ============================================================================= // =============================================================================
// GENERATE TEST CONTENT // GENERATE TEST CONTENT
// ============================================================================= // =============================================================================