当前位置: 首页>>代码示例>>C++>>正文


C++ SerializeBuffer::data方法代码示例

本文整理汇总了C++中SerializeBuffer::data方法的典型用法代码示例。如果您正苦于以下问题:C++ SerializeBuffer::data方法的具体用法?C++ SerializeBuffer::data怎么用?C++ SerializeBuffer::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SerializeBuffer的用法示例。


在下文中一共展示了SerializeBuffer::data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

/**
 * Send data via MPI to benchmark the effective link speed at application level.
 */
int main(int argc, char **argv)
{
    BenchmarkOptions options(argc, argv);
    if (options.getHelp_)
    {
        options.showSyntax();
        return 0;
    }

    MPIChannel mpiChannel(argc, argv);

    // Send buffer
    std::vector<char> noiseBuffer(options.dataSize_);
    for (std::vector<char>::iterator it = noiseBuffer.begin(); it != noiseBuffer.end(); ++it)
        *it = rand();
    const std::string serializedData = SerializeBuffer::serialize(noiseBuffer);

    // Receive buffer
    SerializeBuffer buffer;
    Timer timer;
    size_t counter = 0;

    mpiChannel.globalBarrier();
    timer.start();

    while(counter < options.packetsCount_)
    {
        if (mpiChannel.getRank() == RANK0)
            mpiChannel.broadcast(MPI_MESSAGE_TYPE_NONE, serializedData);
        else
        {
            const MPIHeader header = mpiChannel.receiveHeader(RANK0);
            buffer.setSize(header.size);
            mpiChannel.receiveBroadcast(buffer.data(), header.size, RANK0);
        }
        ++counter;
    }

    const float time = timer.elapsed() / 1000.f;

    if (mpiChannel.getRank() == RANK0)
    {
        std::cout << "Object size [Mbytes]: " << (float)serializedData.size() / MEGABYTE << std::endl;
        std::cout << "Time to send " << counter << " objects: " << time << std::endl;
        std::cout << "Time per object: " << time / counter << std::endl;
        std::cout << "Throughput [Mbytes/sec]: " << counter * serializedData.size() / time / MEGABYTE << std::endl;
    }

    return 0;
}
开发者ID:BlueBrain,项目名称:DisplayCluster,代码行数:53,代码来源:dcBenchmarkMPI.cpp

示例2: send_packet

void GameNetConnection::send_packet(SerializeBuffer& serializer, int receiver) {
	_connection->send_message(serializer.data(), serializer.size(), receiver);

}
开发者ID:Zolomon,项目名称:lanarts,代码行数:4,代码来源:GameNetConnection.cpp


注:本文中的SerializeBuffer::data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。