Code Search for Developers
 
 
  

netperf.cpp from Equalizer - Multipipe Rendering at Krugle


Show netperf.cpp syntax highlighted

// Tests network throughput
// Usage:
//   Server: ./netperf -s (<connectionDescription>)
//   Client: ./netperf -c <connectionDescription>
//     connectionDescription: hostname(:port)(:(SDP|TCPIP))

#include <test.h>
#include <eq/base/monitor.h>
#include <eq/net/connection.h>
#include <eq/net/connectionDescription.h>
#include <eq/net/connectionSet.h>
#include <eq/net/init.h>

#include <iostream>

using namespace eqNet;
using namespace eqBase;
using namespace std;

#define PACKETSIZE (100 * 1048576)
#define NPACKETS   10

int main( int argc, char **argv )
{
    if( argc != 2 && argc != 3 )
    {
        cout << "Usage: " << argv[0] << " (-s|-c) (connectionDescription)" 
             << endl;
        exit( EXIT_FAILURE );
    }

    eqNet::init( argc, argv );

    RefPtr<Connection>            connection = 
        Connection::create( CONNECTIONTYPE_TCPIP );
    RefPtr<ConnectionDescription> connDesc   = connection->getDescription();
    connDesc->TCPIP.port = 4242;
    if( argc == 3 )
    {
        string desc = argv[2];
        connDesc->fromString( desc );
    }

    void*         buffer    = calloc( 1, PACKETSIZE );
    const float   mBytesSec = PACKETSIZE / 1024.0f / 1024.0f * 1000.0f;
    Clock         clock;

    if( argv[1] == string( "-c" )) // client
    {
        TEST( connection->connect( ));

        for( unsigned i=0; i<NPACKETS; )
        {
            clock.reset();
            if( connection->recv( buffer, PACKETSIZE ))
            {
                const float time = clock.getTimef();
                EQINFO << "Recv perf: " << mBytesSec / time << "MB/s (" 
                       << time << "ms)" << endl;
                ++i;
            }
        }
    }
    else
    {
        TEST( connection->listen( ));

        RefPtr<Connection> client = connection->accept();
        EQINFO << "accepted connection" << endl;
        connection->close();
        connection = client;

        for( unsigned i=0; i<NPACKETS; ++i )
        {
            clock.reset();
            TEST( connection->send( buffer, PACKETSIZE ));
            const float time = clock.getTimef();
            EQINFO << "Send perf: " << mBytesSec / time << "MB/s (" << time 
                   << "ms)" << endl;
        }
    }

    free( buffer );
    connection->close();
    return EXIT_SUCCESS;
}




See more files for this project here

Equalizer - Multipipe Rendering

Equalizer is a programming interface and resource management system for scalable graphics applications for clusters and shared memory systems. It is build upon a scalable programming interface solving the problems common to any multipipe application.

Project homepage: http://sourceforge.net/projects/equalizer
Programming language(s): C,C++
License: lgpl21

  Makefile
  netperf.cpp