[complement-svn] SF.net SVN: complement: [1727] trunk/complement/explore/lib/sockios
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-09-07 11:07:27
|
Revision: 1727 http://complement.svn.sourceforge.net/complement/?rev=1727&view=rev Author: complement Date: 2007-09-07 04:07:26 -0700 (Fri, 07 Sep 2007) Log Message: ----------- performance measure for sockios: client read 8K blocks, client write 8K blocks, cleint write/read 8K blocks Added Paths: ----------- trunk/complement/explore/lib/sockios/perf/ trunk/complement/explore/lib/sockios/perf/Makefile trunk/complement/explore/lib/sockios/perf/Makefile.inc trunk/complement/explore/lib/sockios/perf/perf.cc trunk/complement/explore/lib/sockios/perf/sockios_perf.cc trunk/complement/explore/lib/sockios/perf/sockios_perf.h trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.cc trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.h Property changes on: trunk/complement/explore/lib/sockios/perf ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/lib/sockios/perf/Makefile =================================================================== --- trunk/complement/explore/lib/sockios/perf/Makefile (rev 0) +++ trunk/complement/explore/lib/sockios/perf/Makefile 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,32 @@ +# -*- Makefile -*- Time-stamp: <07/09/05 22:48:46 ptr> + +SRCROOT := ../../.. + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + + +INCLUDES += -I$(SRCROOT)/include +ifdef BOOST_DIR +INCLUDES += -I$(BOOST_INCLUDE_DIR) +endif +DEFS += -D__FIT_EXAM + +LIBMT_DIR = ${CoMT_DIR}/lib/mt +LIBSOCK_DIR = ${CoMT_DIR}/lib/sockios +LIBEXAM_DIR = ${CoMT_DIR}/lib/exam +# LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework + +ifeq ($(OSNAME),linux) +release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +ifndef WITHOUT_STLPORT +stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +endif +dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +endif + +release-shared : LDLIBS = -lxmt -lsockios -lexam +ifndef WITHOUT_STLPORT +stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lexamstlg +endif +dbg-shared : LDLIBS = -lxmtg -lsockiosg -lexamg Added: trunk/complement/explore/lib/sockios/perf/Makefile.inc =================================================================== --- trunk/complement/explore/lib/sockios/perf/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/sockios/perf/Makefile.inc 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,4 @@ +# -*- makefile -*- Time-stamp: <07/09/05 22:48:36 ptr> + +PRGNAME = sockios_perf +SRC_CC = perf.cc sockios_perf.cc sockios_perf_suite.cc Added: trunk/complement/explore/lib/sockios/perf/perf.cc =================================================================== --- trunk/complement/explore/lib/sockios/perf/perf.cc (rev 0) +++ trunk/complement/explore/lib/sockios/perf/perf.cc 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,17 @@ +// -*- C++ -*- Time-stamp: <07/09/05 22:46:17 ptr> + +/* + * + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#include "sockios_perf_suite.h" + +int main( int, char ** ) +{ + return sockios_perf_suite(0); +} Added: trunk/complement/explore/lib/sockios/perf/sockios_perf.cc =================================================================== --- trunk/complement/explore/lib/sockios/perf/sockios_perf.cc (rev 0) +++ trunk/complement/explore/lib/sockios/perf/sockios_perf.cc 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,188 @@ +// -*- C++ -*- Time-stamp: <07/09/06 11:17:21 ptr> + +/* + * + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#include "sockios_perf.h" +#include <exam/suite.h> + +#include <sockios/sockstream> +#include <sockios/sockmgr.h> + +#include <mt/shm.h> +#include <sys/wait.h> +#include <signal.h> +#include <algorithm> + +using namespace std; + +sockios_perf::sockios_perf() // : +// fname( "/tmp/sockios_perf.shm" ) +{ +// try { +// seg.allocate( fname.c_str(), 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); +// } +// catch ( const xmt::shm_bad_alloc& err ) { +// EXAM_ERROR_ASYNC( err.what() ); +// } +} + +sockios_perf::~sockios_perf() +{ +// seg.deallocate(); +// unlink( fname.c_str() ); +} + +/* ************************************************************ */ + +class SrvR +{ + public: + SrvR( sockstream& ) + { } + + ~SrvR() + { } + + void connect( sockstream& s ) + { + s.read( buf, 1024*8 ); + EXAM_CHECK_ASYNC( s.good() ); + } + + void close() + { } + + private: + char buf[10240]; +}; + +class SrvW +{ + public: + SrvW( sockstream& s ) + { + fill( buf, buf + 10240, ' ' ); + for ( int i = 0; i < 10; ++i ) { + s.write( buf, 1024*8 ); + EXAM_CHECK_ASYNC( s.good() ); + } + } + + ~SrvW() + { } + + void connect( sockstream& ) + { } + + void close() + { } + + private: + char buf[10240]; +}; + +class SrvRW +{ + public: + SrvRW( sockstream& ) + { } + + ~SrvRW() + { } + + void connect( sockstream& s ) + { + s.read( buf, 1024*8 ); + EXAM_CHECK_ASYNC( s.good() ); + s.write( buf, 1024*8 ).flush(); + EXAM_CHECK_ASYNC( s.good() ); + } + + void close() + { } + + private: + char buf[10240]; +}; + +int EXAM_IMPL(sockios_perf::exchange1) +{ + sockmgr_stream_MP<SrvR> srv( 6480 ); + + { + EXAM_REQUIRE( srv.good() && srv.is_open() ); + + sockstream s1( "localhost", 6480 ); + char buf[10240]; + + fill( buf, buf + 10240, ' ' ); + + for ( int i = 0; i < 10; ++i ) { + s1.write( buf, 1024 * 8 ); + EXAM_CHECK_ASYNC( s1.good() ); + } + } + + srv.close(); + srv.wait(); + + return EXAM_RESULT; +} + +int EXAM_IMPL(sockios_perf::exchange2) +{ + sockmgr_stream_MP<SrvW> srv( 6480 ); + + { + EXAM_REQUIRE( srv.good() && srv.is_open() ); + + sockstream s1( "localhost", 6480 ); + char buf[10240]; + + for ( int i = 0; i < 10; ++i ) { + s1.read( buf, 1024 * 8 ); + EXAM_CHECK_ASYNC( s1.good() ); + } + } + + srv.close(); + srv.wait(); + + return EXAM_RESULT; +} + +int EXAM_IMPL(sockios_perf::exchange3) +{ + sockmgr_stream_MP<SrvRW> srv( 6480 ); + + { + EXAM_REQUIRE( srv.good() && srv.is_open() ); + + sockstream s1( "localhost", 6480 ); + char buf[10240]; + + for ( int i = 0; i < 10; ++i ) { + s1.write( buf, 1024 * 8 ).flush(); + EXAM_CHECK_ASYNC( s1.good() ); + s1.read( buf, 1024 * 8 ); + EXAM_CHECK_ASYNC( s1.good() ); + } + } + + srv.close(); + srv.wait(); + + return EXAM_RESULT; +} + +xmt::Thread::ret_t client_thr( void *p ) +{ + return 0; +} Added: trunk/complement/explore/lib/sockios/perf/sockios_perf.h =================================================================== --- trunk/complement/explore/lib/sockios/perf/sockios_perf.h (rev 0) +++ trunk/complement/explore/lib/sockios/perf/sockios_perf.h 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,36 @@ +// -*- C++ -*- Time-stamp: <07/09/06 11:12:29 ptr> + +/* + * + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#ifndef __sockios_perf_h +#define __sockios_perf_h + +#include <exam/suite.h> +#include <string> +#include <mt/shm.h> + +class sockios_perf +{ + public: + sockios_perf(); + ~sockios_perf(); + + int EXAM_DECL(exchange1); + int EXAM_DECL(exchange2); + int EXAM_DECL(exchange3); + + private: + // const std::string fname; + // xmt::shm_alloc<0> seg; + // xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; + // xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; +}; + +#endif // __sockios_perf_h Added: trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.cc =================================================================== --- trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.cc (rev 0) +++ trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.cc 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,33 @@ +// -*- C++ -*- Time-stamp: <07/09/06 11:11:58 ptr> + +/* + * + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#include "sockios_perf_suite.h" +#include "sockios_perf.h" + +#include <exam/suite.h> +#include <iostream> + +using namespace std; + +int EXAM_IMPL(sockios_perf_suite) +{ + exam::trivial_time_logger tlogger( std::cout ); + exam::test_suite t( "libsockios performance test suite", 10 ); + t.set_logger( &tlogger ); + + sockios_perf p; + + t.add( &sockios_perf::exchange1, p, "client write 8K blocks" ); + t.add( &sockios_perf::exchange2, p, "client read 8K blocks" ); + t.add( &sockios_perf::exchange3, p, "client write/read 8K blocks" ); + + return t.girdle(); +} Added: trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.h =================================================================== --- trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.h (rev 0) +++ trunk/complement/explore/lib/sockios/perf/sockios_perf_suite.h 2007-09-07 11:07:26 UTC (rev 1727) @@ -0,0 +1,19 @@ +// -*- C++ -*- Time-stamp: <07/09/05 22:47:06 ptr> + +/* + * + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#ifndef __sockios_perf_suite_h +#define __sockios_perf_suite_h + +#include <exam/suite.h> + +int EXAM_DECL(sockios_perf_suite); + +#endif // __sockios_perf_suite_h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |