Skip to content

Commit

Permalink
total time calculations for is_readable and dirlist
Browse files Browse the repository at this point in the history
  • Loading branch information
joe9663 committed Dec 3, 2021
1 parent 4f4caa1 commit 9325810
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions admin/class-boldgrid-backup-admin-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,8 @@ public function get_filelist( $dirpath ) {
global $wp_filesystem;

// Validate input.
static $is_readable_total_time = 0;

$is_readable_time_start = microtime( true );

if ( empty( $dirpath ) || ! $wp_filesystem->is_readable( $dirpath ) ) {
Expand All @@ -1397,7 +1399,9 @@ public function get_filelist( $dirpath ) {

$is_readable_time_end = microtime( true );

$this->logger->add( 'is_readable Duration: ' . ( $is_readable_time_end - $is_readable_time_start ) );
$is_readable_total_time += ( $is_readable_time_end - $is_readable_time_start );

$this->logger->add( 'is_readable Duration: ' . $is_readable_total_time );

// Remove any training slash in dirpath.
$dirpath = untrailingslashit( $dirpath );
Expand All @@ -1408,13 +1412,17 @@ public function get_filelist( $dirpath ) {
}

// Get the non-recursive directory listing for the specified path.
static $dirlist_total_time = 0;

$dirlist_time_start = microtime( true );

$dirlist = $wp_filesystem->dirlist( $dirpath, true, false );

$dirlist_time_end = microtime( true );

$this->logger->add( '$dirlist Duration: ' . ( $dirlist_time_end - $dirlist_time_start ) );
$dirlist_total_time += ( $dirlist_time_end - $dirlist_time_start );

$this->logger->add( '$dirlist Duration: ' . $dirlist_total_time );

// Initialize $filelist.
$filelist = [];
Expand Down Expand Up @@ -1755,7 +1763,7 @@ public function archive_files( $save = false, $dryrun = false ) {
$this->logger->add( 'Dump of database complete! $status = ' . print_r( $status, 1 ) ); // phpcs:ignore
$this->logger->add_memory();
$this->logger->add_separator();
$this->logger->add( 'after separator' );

if ( false === $status || ! empty( $status['error'] ) ) {
$error = ! empty( $status['error'] ) ? $status['error'] : __( 'An unknown error occurred when backing up the database.', 'boldgrid-backup' );
$this->logger->add( $error );
Expand Down

0 comments on commit 9325810

Please sign in to comment.