fastcommon_file_put_contents bug fixed

pull/37/head
yuqing 2017-02-15 16:04:06 +08:00
parent 751cb2718a
commit f7cd971224
2 changed files with 23 additions and 21 deletions

View File

@ -1267,7 +1267,7 @@ ZEND_FUNCTION(fastcommon_file_put_contents)
args[0] = &zfilename;
args[1] = zdata;
args[1] = &zflags;
args[2] = &zflags;
args[3] = zcontext;
result = zend_call_user_function_wrapper(EG(function_table), NULL,
file_put_contents_func, return_value, 4, args TSRMLS_CC);

View File

@ -1,19 +1,21 @@
<?php
define('TEST_FLAGS', FILE_APPEND);
define('LOOP_COUNT', 102400);
function test_fastcommon_file_put_contents()
{
$start = microtime(true);
for ($i=0; $i<102400; $i++)
for ($i=0; $i<LOOP_COUNT; $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);
fastcommon_file_put_contents("/tmp/test.log", "this is a test\n", TEST_FLAGS);
fastcommon_file_put_contents("/tmp/test1.log", "this is a test11\n", TEST_FLAGS);
fastcommon_file_put_contents("/tmp/test1.log", "this is a test12\n", TEST_FLAGS);
fastcommon_file_put_contents("/tmp/test2.log", "this is a test21\n", TEST_FLAGS);
fastcommon_file_put_contents("/tmp/test2.log", "this is a test22\n", TEST_FLAGS);
fastcommon_file_put_contents("/tmp/test2.log", "this is a test23\n", TEST_FLAGS);
fastcommon_file_put_contents("/tmp/test3.log", "this is a test31\n", TEST_FLAGS);
fastcommon_file_put_contents("/tmp/test3.log", "this is a test32\n", TEST_FLAGS);
fastcommon_file_put_contents("/tmp/test3.log", "this is a test33\n", TEST_FLAGS);
}
$end = microtime(true);
@ -24,17 +26,17 @@ function test_fastcommon_file_put_contents()
function test_file_put_contents()
{
$start = microtime(true);
for ($i=0; $i<102400; $i++)
for ($i=0; $i<LOOP_COUNT; $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);
file_put_contents("/tmp/test.log", "this is a test\n", TEST_FLAGS);
file_put_contents("/tmp/test1.log", "this is a test11\n", TEST_FLAGS);
file_put_contents("/tmp/test1.log", "this is a test12\n", TEST_FLAGS);
file_put_contents("/tmp/test2.log", "this is a test21\n", TEST_FLAGS);
file_put_contents("/tmp/test2.log", "this is a test22\n", TEST_FLAGS);
file_put_contents("/tmp/test2.log", "this is a test23\n", TEST_FLAGS);
file_put_contents("/tmp/test3.log", "this is a test31\n", TEST_FLAGS);
file_put_contents("/tmp/test3.log", "this is a test32\n", TEST_FLAGS);
file_put_contents("/tmp/test3.log", "this is a test33\n", TEST_FLAGS);
}
$end = microtime(true);