本文整理汇总了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;
}
示例2: send_packet
void GameNetConnection::send_packet(SerializeBuffer& serializer, int receiver) {
_connection->send_message(serializer.data(), serializer.size(), receiver);
}