-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add php extension function: fastcommon_file_put_contents
- Loading branch information
yuqing
committed
Feb 15, 2017
1 parent
c78f6b1
commit df428e6
Showing
9 changed files
with
382 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
function test_fastcommon_file_put_contents() | ||
{ | ||
$start = microtime(true); | ||
for ($i=0; $i<102400; $i++) | ||
{ | ||
fastcommon_file_put_contents("/tmp/test.log", "this is a test\n", FILE_APPEND); | ||
fastcommon_file_put_contents("/tmp/test1.log", "this is a test11\n", FILE_APPEND); | ||
fastcommon_file_put_contents("/tmp/test1.log", "this is a test12\n", FILE_APPEND); | ||
fastcommon_file_put_contents("/tmp/test2.log", "this is a test21\n", FILE_APPEND); | ||
fastcommon_file_put_contents("/tmp/test2.log", "this is a test22\n", FILE_APPEND); | ||
fastcommon_file_put_contents("/tmp/test2.log", "this is a test23\n", FILE_APPEND); | ||
fastcommon_file_put_contents("/tmp/test3.log", "this is a test31\n", FILE_APPEND); | ||
fastcommon_file_put_contents("/tmp/test3.log", "this is a test32\n", FILE_APPEND); | ||
fastcommon_file_put_contents("/tmp/test3.log", "this is a test33\n", FILE_APPEND); | ||
} | ||
|
||
$end = microtime(true); | ||
$timeUsed = round($end - $start, 3); | ||
echo "fastcommon_file_put_contents time used: $timeUsed\n"; | ||
} | ||
|
||
function test_file_put_contents() | ||
{ | ||
$start = microtime(true); | ||
for ($i=0; $i<102400; $i++) | ||
{ | ||
file_put_contents("/tmp/test.log", "this is a test\n", FILE_APPEND); | ||
file_put_contents("/tmp/test1.log", "this is a test11\n", FILE_APPEND); | ||
file_put_contents("/tmp/test1.log", "this is a test12\n", FILE_APPEND); | ||
file_put_contents("/tmp/test2.log", "this is a test21\n", FILE_APPEND); | ||
file_put_contents("/tmp/test2.log", "this is a test22\n", FILE_APPEND); | ||
file_put_contents("/tmp/test2.log", "this is a test23\n", FILE_APPEND); | ||
file_put_contents("/tmp/test3.log", "this is a test31\n", FILE_APPEND); | ||
file_put_contents("/tmp/test3.log", "this is a test32\n", FILE_APPEND); | ||
file_put_contents("/tmp/test3.log", "this is a test33\n", FILE_APPEND); | ||
} | ||
|
||
$end = microtime(true); | ||
$timeUsed = round($end - $start, 3); | ||
echo "file_put_contents time used: $timeUsed\n"; | ||
} | ||
|
||
test_file_put_contents(); | ||
echo "sleep ...\n"; | ||
sleep(2); | ||
echo "sleep done.\n"; | ||
test_fastcommon_file_put_contents(); | ||
|
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
Oops, something went wrong.