Created
October 3, 2019 19:07
-
-
Save charliepark/e2133928703c1d2ce87259d2bc207fea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?PHP | |
shell_exec("touch messages1.txt"); | |
shell_exec("touch messages2.txt"); | |
$time_1 = microtime(true); | |
for ($i=1; $i<1000; $i++) { | |
file_put_contents('messages1.txt', "This is the sample text\n", FILE_APPEND); | |
} | |
$time_delta_1 = microtime(true) - $time_1; | |
$time_log_message_1 = "$time_delta_1 delta for file_put_contents\n"; | |
$time_2 = microtime(true); | |
for ($i=1; $i<1000; $i++) { | |
shell_exec("echo 'This is the sample text' >> messages2.txt"); | |
} | |
$time_delta_2 = microtime(true) - $time_2; | |
$time_log_message_2 = "$time_delta_2 delta for shell_exec(echo)\n\n"; | |
echo("$time_log_message_1<br>$time_log_message_2"); | |
shell_exec(": > messages1.txt"); | |
shell_exec(": > messages2.txt"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fairly standard output:
So … use
file_put_contents
.