1
0
mirror of https://github.com/php/php-src.git synced 2026-04-15 20:11:02 +02:00

Fix slowest tests

This commit is contained in:
Gabriel Caruso
2019-11-02 16:29:42 +01:00
parent 0f89d407fc
commit fc99e89baf
21 changed files with 59 additions and 37 deletions

View File

@@ -40,7 +40,6 @@ function stat_fn( $filename ) {
echo "-- inode change time is => ";
print( @date( 'Y:M:D:H:i:s', filectime($filename) ) )."\n";
clearstatcache();
}
echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n";
@@ -49,12 +48,12 @@ $file_path = __DIR__;
$file_handle = fopen("$file_path/005_variation1.tmp", "w");
fclose($file_handle);
stat_fn("$file_path/005_variation1.tmp");
sleep(2);
sleep(1);
$file_handle = fopen("$file_path/005_variation2.tmp", "w");
fclose($file_handle);
stat_fn("$file_path/005_variation2.tmp");
sleep(2);
sleep(1);
$file_handle = fopen("$file_path/005_variation3.tmp", "w");
fclose($file_handle);
@@ -70,13 +69,13 @@ $file_name = "$file_path/005_variation1.tmp";
$file_write_handle = fopen($file_name, "w");
fclose($file_write_handle);
stat_fn($file_name);
sleep(2);
sleep(1);
/* filectime + 2 */
echo "\n-- Checking different times, after changing the file permission --\n";
chmod($file_name, 0777);
stat_fn($file_name);
sleep(2);
sleep(1);
/* filemtime + 2 & filectime + 2 */
echo "\n-- Checking different times, after writing into the file --\n";
@@ -84,7 +83,7 @@ $file_write_handle = fopen($file_name, "w");
fwrite($file_write_handle, "Hello, world");
fclose($file_write_handle);
stat_fn($file_name);
sleep(2);
sleep(1);
/* fileatime + 2 */
echo "\n-- Checking different times, after reading from the file --\n";
@@ -92,42 +91,54 @@ $file_read_handle = fopen($file_name ,"r");
fread($file_read_handle, 10);
fclose( $file_read_handle);
stat_fn($file_name);
sleep(2);
sleep(1);
/* No change */
echo "\n-- Checking different times, after making a copy of the file --\n";
echo "\n-- Checking same times, after creating a softlink to the file --\n";
symlink($file_name, "$file_path/005_variation_softlink.tmp");
stat_fn($file_name);
sleep(1);
/* filectime + 2 */
echo "\n-- Checking different times, after creating a hardlink to the file --\n";
link($file_name, "$file_path/005_variation_hardlink.tmp");
stat_fn($file_name);
sleep(1);
/* No change */
echo "\n-- Checking same times, after making a copy of the file --\n";
$file_copy = "$file_path/005_variation_copy.tmp";
copy($file_name, $file_copy);
stat_fn($file_name);
sleep(2);
sleep(1);
/* fileatime + 2 */
echo "\n-- Checking different times, after performing is_file() operation on the file --\n";
is_file($file_name);
stat_fn($file_name);
sleep(2);
sleep(1);
echo "\n*** Testing touch() function with different time values ***\n";
$file_name2 = $file_path."/005_variation_touch.tmp";
$file_handle = fopen($file_name2, "w");
fclose($file_handle);
sleep(2);
sleep(1);
/* Time is not mentioned */
var_dump( touch($file_name2) ); //set to current system time
stat_fn($file_name2);
sleep(2);
sleep(1);
/* set to access(creation time of the file) time */
var_dump( touch($file_name2, @date(fileatime($file_name2))) );
stat_fn($file_name2);
sleep(2);
sleep(1);
/* set to access time of $file_name2 */
var_dump( touch($file_path."/005_variation_touch_fly.tmp", @date(fileatime($file_name2)), time()) );
stat_fn($file_name2);
sleep(2);
sleep(1);
/* set to default value, with Invalid timestamps */
var_dump( touch($file_name2, 10) );
@@ -184,7 +195,17 @@ unlink($file_path."/005_variation_touch_new.tmp");
-- File modification time is => %d:%s:%s:%d:%d:%d
-- inode change time is => %d:%s:%s:%d:%d:%d
-- Checking different times, after making a copy of the file --
-- Checking same times, after creating a softlink to the file --
-- File access time is => %d:%s:%s:%d:%d:%d
-- File modification time is => %d:%s:%s:%d:%d:%d
-- inode change time is => %d:%s:%s:%d:%d:%d
-- Checking different times, after creating a hardlink to the file --
-- File access time is => %d:%s:%s:%d:%d:%d
-- File modification time is => %d:%s:%s:%d:%d:%d
-- inode change time is => %d:%s:%s:%d:%d:%d
-- Checking same times, after making a copy of the file --
-- File access time is => %d:%s:%s:%d:%d:%d
-- File modification time is => %d:%s:%s:%d:%d:%d
-- inode change time is => %d:%s:%s:%d:%d:%d

View File

@@ -31,7 +31,7 @@ echo "*** Testing stat() on directory after using is_dir() on it ***\n";
$old_stat = stat($dirname);
// clear the cache
clearstatcache();
sleep(2);
sleep(1);
var_dump( is_dir($dirname) );
$new_stat = stat($dirname);

View File

@@ -31,7 +31,7 @@ echo "*** Testing stat() on a file after using is_file() on it ***\n";
$old_stat = stat($filename);
// clear the stat
clearstatcache();
sleep(2);
sleep(1);
var_dump( is_file($filename) );
$new_stat = stat($filename);
// compare self stats

View File

@@ -36,7 +36,7 @@ $linkname = "$file_path/lstat_stat_variation12_link.tmp";
$old_stat = lstat($linkname);
// clear the stat
clearstatcache();
sleep(2);
sleep(1);
var_dump( is_link($linkname) );
$new_stat = lstat($linkname);
// compare self stats

View File

@@ -30,7 +30,7 @@ fclose($file_handle);
$old_stat = stat($filename);
// clear the stat
clearstatcache();
sleep(2);
sleep(1);
// opening file again in read mode
$file_handle = fopen($filename, "r"); // read file
fclose($file_handle);

View File

@@ -28,7 +28,7 @@ fclose($fp);
// checking stat() on file after changing its permission
echo "*** Testing lstat() on a file after changing its access permission ***\n";
$old_stat = stat($filename);
sleep(2);
sleep(1);
var_dump( chmod($filename, 0777) );
// clear the stat
clearstatcache();

View File

@@ -27,7 +27,7 @@ $dirname = "$file_path/lstat_stat_variation17";
mkdir($dirname);
$old_stat = stat($dirname);
sleep(2);
sleep(1);
var_dump( chmod($dirname, 0777) );
// clear the stat
clearstatcache();

View File

@@ -33,7 +33,7 @@ echo "*** Testing stat() on file by truncating it to given size ***\n";
$old_stat = stat($filename);
// clear the cache
clearstatcache();
sleep(2);
sleep(1);
// opening file in r/w mode
$file_handle = fopen($filename, "r+");
var_dump( ftruncate($file_handle, 512) ); // truncate it

View File

@@ -33,7 +33,7 @@ echo "*** Testing stat() for file after using touch() on the file ***\n";
$old_stat = stat($file_name);
// clear the cache
clearstatcache();
sleep(2);
sleep(1);
var_dump( touch($file_name) );
$new_stat = stat($file_name);

View File

@@ -33,7 +33,7 @@ echo "*** Testing stat() for directory after using touch() on the directory ***\
$old_stat = stat($dir_name);
// clear the cache
clearstatcache();
sleep(2);
sleep(1);
var_dump( touch($dir_name) );
$new_stat = stat($dir_name);

View File

@@ -30,7 +30,7 @@ echo "*** Testing stat() on dir after subdir and file is created in it ***\n";
$dirname = "$file_path/lstat_stat_variation8";
$old_stat = stat($dirname);
clearstatcache();
sleep(2);
sleep(1);
mkdir("$dirname/lstat_stat_variation8_subdir");
$file_handle = fopen("$dirname/lstat_stat_variation8a.tmp", "w");
fclose($file_handle);

View File

@@ -26,7 +26,7 @@ mkdir($dirname);
// stat of the dir created
$dir_stat = stat($dirname);
clearstatcache();
sleep(2);
sleep(1);
// creating file
$filename = "$dirname/stat_basic_私はガラスを食べられます.tmp";
@@ -34,7 +34,7 @@ $file_handle = fopen($filename, "w");
fclose($file_handle);
// stat of the file created
$file_stat = stat($filename);
sleep(2);
sleep(1);
// now new stat of the dir after file is created
$new_dir_stat = stat($dirname);

View File

@@ -34,7 +34,7 @@ $file_handle = fopen($filename, "w");
fclose($file_handle);
// stat of the file created
$file_stat = stat($filename);
sleep(2);
sleep(1);
// now new stat of the dir after file is created
$new_dir_stat = stat($dirname);

View File

@@ -35,7 +35,7 @@ $old_filename = "$file_path/stat_variation1_私はガラスを食べられます
$new_filename = "$file_path/stat_variation1a_私はガラスを食べられます.tmp";
$old_stat = stat($old_filename);
clearstatcache();
sleep(2);
sleep(1);
var_dump( rename($old_filename, $new_filename) );
$new_stat = stat($new_filename);

View File

@@ -35,7 +35,7 @@ $old_filename = "$file_path/stat_variation1.tmp";
$new_filename = "$file_path/stat_variation1a.tmp";
$old_stat = stat($old_filename);
clearstatcache();
sleep(2);
sleep(1);
var_dump( rename($old_filename, $new_filename) );
$new_stat = stat($new_filename);

View File

@@ -32,7 +32,7 @@ echo "*** Testing stat(): writing to a file ***\n";
echo "-- Testing stat() on file after data is written in it --\n";
$old_stat = stat($filename);
clearstatcache();
sleep(2);
sleep(1);
$file_handle = fopen($filename, "w"); // temp file
fwrite($file_handle, "Hello World");
fclose($file_handle);

View File

@@ -30,7 +30,7 @@ echo "-- Testing stat() on dir after subdir and file is created in it --\n";
$dirname = "$file_path/stat_variation3";
$old_stat = stat($dirname);
clearstatcache();
sleep(2);
sleep(1);
mkdir("$dirname/stat_variation3_subdir");
$file_handle = fopen("$dirname/stat_variation3a.tmp", "w");
fclose($file_handle);

View File

@@ -36,7 +36,7 @@ $old_dirname = "$file_path/stat_variation4";
$old_stat = stat($old_dirname);
// clear the cache
clearstatcache();
sleep(2);
sleep(1);
var_dump( is_dir($old_dirname) );
$new_stat = stat($old_dirname);

View File

@@ -32,7 +32,7 @@ fclose($file_handle);
$old_stat = stat($filename);
// clear the stat
clearstatcache();
sleep(2);
sleep(1);
// opening file again in read mode
$file_handle = fopen($filename, "r"); // read file
fclose($file_handle);

View File

@@ -32,11 +32,12 @@ fclose($file_handle);
// checking stat() on file
echo "\n*** Testing stat() on file with miscellaneous file permission and content ***\n";
clearstatcache();
$old_stat = stat($filename);
sleep(1);
var_dump( chmod($filename, 0777) );
// clear the stat
clearstatcache();
sleep(2);
$new_stat = stat($filename);
// compare self stats
var_dump( compare_self_stat($old_stat) );
@@ -50,10 +51,10 @@ clearstatcache(); // clear statement cache
// checking stat() on directory
echo "\n*** Testing stat() on directory with miscellaneous file permission ***\n";
$old_stat = stat($dirname);
sleep(1);
var_dump( chmod($dirname, 0777) );
// clear the stat
clearstatcache();
sleep(2);
$new_stat = stat($dirname);
// compare self stats
var_dump( compare_self_stat($old_stat) );

View File

@@ -37,7 +37,7 @@ fclose($file_handle);
clearstatcache(true, $filename);
$old_stat = stat($filename);
// clear the cache
sleep(2);
sleep(1);
// opening file in r/w mode
$file_handle = fopen($filename, "r+");