int test_press( long count ) { #if ( defined _WIN32 ) || ( defined __linux__ ) || ( defined _AIX ) LongToLong llBegin , llEnd , llDiff ; double dPerf ; long l ; LOG *pret = NULL ; pret = CreateLogHandleG() ; if( pret == NULL ) { printf( "创建日志句柄失败errno[%d]\n" , errno ); return -1; } else { /* printf( "创建日志句柄成功[%p]\n" , GetGlobalLOG() ); */ } /* SetLogOptions( press , LOG_OPTION_OPEN_ONCE ); */ SetLogOutputG( LOG_OUTPUT_FILE , "test_press_mpt_tls.log" , LOG_NO_OUTPUTFUNC ); SetLogLevelG( LOG_LEVEL_INFO ); SetLogStylesG( LOG_STYLES_PRESS , LOG_NO_STYLEFUNC ); SetLogRotateModeG( LOG_ROTATEMODE_SIZE ); SetLogRotateSizeG( 10*1024*1024 ); SetLogRotatePressureFactorG( 20 ); llBegin = GetUnixSecondsExactly() ; for( l = 1 ; l <= count ; l++ ) { WriteInfoLogG( __FILE__ , __LINE__ , "log" ); } llEnd = GetUnixSecondsExactly() ; llDiff.high = llEnd.high - llBegin.high ; llDiff.low = llEnd.low - llBegin.low ; if( llDiff.low < 0 ) { llDiff.low += 1000000 ; llDiff.high--; } dPerf = (double)(count) / ( (double)(llDiff.high) + (double)(llDiff.low) / 1000000 ) ; printf( "总耗时[%ld.%03ld] 平均每秒输出行日志[%.2lf]条\n" , llDiff.high , llDiff.low , dPerf ); DestroyLogHandleG(); /* printf( "销毁日志句柄\n" ); */ #endif return 0; }
int test_press( long count ) { LOG *press = NULL ; LongToLong llBegin , llEnd , llDiff ; double dPerf ; long l ; press = CreateLogHandle() ; if( press == NULL ) { printf( "创建press日志句柄失败errno[%d]\n" , errno ); return -1; } else { printf( "创建press日志句柄成功\n" ); } /* SetLogOptions( press , LOG_OPTION_OPEN_ONCE ); */ SetLogOutput( press , LOG_OUTPUT_FILE , "test_press.log" , LOG_NO_OUTPUTFUNC ); SetLogLevel( press , LOG_LEVEL_INFO ); SetLogStyles( press , LOG_STYLES_PRESS , LOG_NO_STYLEFUNC ); SetLogRotateMode( press , LOG_ROTATEMODE_SIZE ); SetLogRotateSize( press , 10*1024*1024 ); llBegin = GetUnixSecondsExactly() ; for( l = 1 ; l <= count ; l++ ) { InfoLog( press , __FILE__ , __LINE__ , "log" ); } llEnd = GetUnixSecondsExactly() ; llDiff.high = llEnd.high - llBegin.high ; llDiff.low = llEnd.low - llBegin.low ; if( llDiff.low < 0 ) { llDiff.low += 1000000 ; llDiff.high--; } dPerf = (double)(count) / ( (double)(llDiff.high) + (double)(llDiff.low) / 1000000 ) ; printf( "总耗时[%ld.%03ld] 平均每秒输出行日志[%.2lf]条\n" , llDiff.high , llDiff.low , dPerf ); DestroyLogHandle( press ); printf( "销毁press句柄环境\n" ); return 0; }
int test_press( long count ) { LongToLong llBegin , llEnd , llDiff ; double dPerf ; long l ; llBegin = GetUnixSecondsExactly() ; for( l = 1 ; l <= count ; l++ ) { InfoLog( __FILE__ , __LINE__ , "log" ); } llEnd = GetUnixSecondsExactly() ; llDiff.high = llEnd.high - llBegin.high ; llDiff.low = llEnd.low - llBegin.low ; if( llDiff.low < 0 ) { llDiff.low += 1000000 ; llDiff.high--; } dPerf = (double)(count) / ( (double)(llDiff.high) + (double)(llDiff.low) / 1000000 ) ; /* printf( "总耗时[%ld.%03ld] 平均每秒输出行日志[%.2lf]条\n" , llDiff.high , llDiff.low , dPerf ); */ return 0; }