facebook / facebook/wangle

Does wangle have official benchmark data?

Open
#20 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
3.1k
Forks
547
PR merge metrics
No merged PRs in 30d

Description

I modify the telnet example to echo protocol.

```
/*
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/

#include

#include
#include
#include
#include
#include

using namespace folly;
using namespace wangle;

DEFINE_int32(port, 8096, "echo server port");
DEFINE_int32(frame_length, 10, "echo frame length");

typedef Pipeline EchoPipeline;

class EchoHandler : public HandlerAdapter {
public:
virtual void read(Context* ctx, std::string msg) override {
if (msg.empty())
{
write(ctx, "Please type something.\r\n");
}
else if (msg == "bye")
{
write(ctx, "Have a fabulous day!\r\n").then([ctx, this]{
close(ctx);
});
}
else
{
write(ctx, msg);
}
}

virtual void transportActive(Context* ctx) override {
auto sock = ctx->getTransport();
SocketAddress localAddress;
sock->getLocalAddress(&localAddress);
//write(ctx, "Welcome to " + localAddress.describe() + "!\r\n");
std::cout << "Welcome to " + localAddress.describe() + "!\r\n" << std::endl;
//write(ctx, "Type 'bye' to disconnect.\r\n");
}
};

class EchoPipelineFactory : public PipelineFactory {
public:
EchoPipeline::Ptr newPipeline(std::shared_ptr sock) {
auto pipeline = EchoPipeline::create();
pipeline->addBack(AsyncSocketHandler(sock));
pipeline->addBack(FixedLengthFrameDecoder(FLAGS_frame_length));
pipeline->addBack(StringCodec());
pipeline->addBack(EchoHandler());
pipeline->finalize();

return pipeline;
}
};

int main(int argc, char** argv) {
google::ParseCommandLineFlags(&argc, &argv, true);

ServerBootstrap server;
server.childPipeline(std::make_shared());
server.bind(FLAGS_port);
server.waitForStop();

return 0;
}
```

I test it use my echoclient with 10 bytes playload,then the qps is only 13w。
My hardware:
model name : Intel(R) Xeon(R) CPU E5-2450 v2 @ 2.50GHz
cpu MHz : 2500.000
cache size : 20480 KB
MemTotal: 132133772 kB
OS:
CentOS release 6.3 (Final) with gcc 4.8

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.