Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,11 @@ http_archive(
"https://zlib.net/zlib-1.2.11.tar.gz",
],
)

http_archive(
name = "com_github_google_benchmark",
strip_prefix = "benchmark-1.6.0",
sha256 = "1f71c72ce08d2c1310011ea6436b31e39ccab8c2db94186d26657d41747c85d6",
url = "https://github.com/google/benchmark/archive/v1.6.0.tar.gz"
)

7 changes: 6 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ or In our case we want to use Bazel 5.4.0:
5. Verify Installation:
`bazel --version`

### Then Install libvert:
### Then Install libvirt:
```
sudo apt-get update
sudo apt-get install -y autoconf automake libtool
```

### Add Google Benchmark:
```
sudo apt-get install libbenchmark-dev
```

## To Build:

Under the project root dir:
Expand Down
22 changes: 22 additions & 0 deletions net_http/client/test_client/benchmark/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Description: net_http/client/test_client/testing

package(default_visibility = ["//visibility:private"])

licenses(["notice"])

cc_binary(
name = "evhttp_echo_client",
srcs = ["evhttp_echo_client.cc"],
deps = [
"//net_http/client/test_client/internal:evhttp_client",
],
)
cc_binary(
name = "my_benchmark",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to client_benchmark.

srcs = ["evhttp_echo_client_benchmark.cc"], # Replace with your benchmark source file
deps = [
"@com_github_google_benchmark//:benchmark",
# Add other dependencies your benchmark might have
],
copts = ["-Iexternal/com_github_google_benchmark/include"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* Copyright 2018 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

// A benchmark test client to print the response from the evhttp_echo_server
// URI: /print

#include <iostream>
#include <benchmark/benchmark.h>

#include "net_http/client/test_client/internal/evhttp_connection.h"

namespace {

using net_http::TestClientRequest;
using net_http::TestClientResponse;
using net_http::TestEvHTTPConnection;

const char* global_url; // Global variable to store the URL

bool SendRequest(const char* url) {
auto connection = TestEvHTTPConnection::Connect(url);
if (connection == nullptr) {
std::cerr << "Fail to connect to " << url << std::endl;
return false;
}

TestClientRequest request = {url, "GET", {}, ""};
TestClientResponse response = {};

if (!connection->BlockingSendRequest(request, &response)) {
std::cerr << "Request failed." << std::endl;
return false;
}

// Suppress output for benchmarking
return true;
}

} // namespace

static void BM_SendRequest(benchmark::State& state) {
for (auto _ : state) {
SendRequest(global_url); // Use the global variable
}
}
BENCHMARK(BM_SendRequest);

int main(int argc, char** argv) {
if (argc < 2) {
std::cerr << "Usage: http-client <url>" << std::endl;
return 1;
}

global_url = argv[1]; // Set the global URL from argv

// Run benchmarks
::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
return 0;
}
6 changes: 3 additions & 3 deletions net_http/client/test_client/internal/evhttp_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef TENSORFLOW_SERVING_UTIL_NET_HTTP_CLIENT_TEST_CLIENT_INTERNAL_EVHTTP_CONNECTION_H_
#define TENSORFLOW_SERVING_UTIL_NET_HTTP_CLIENT_TEST_CLIENT_INTERNAL_EVHTTP_CONNECTION_H_
#ifndef NET_HTTP_CLIENT_TEST_CLIENT_INTERNAL_EVHTTP_CONNECTION_H_
#define NET_HTTP_CLIENT_TEST_CLIENT_INTERNAL_EVHTTP_CONNECTION_H_

#include <functional>
#include <memory>
Expand Down Expand Up @@ -94,4 +94,4 @@ class TestEvHTTPConnection final : public TestHTTPClientInterface {

} // namespace net_http

#endif // TENSORFLOW_SERVING_UTIL_NET_HTTP_CLIENT_TEST_CLIENT_INTERNAL_EVHTTP_CONNECTION_H_
#endif // NET_HTTP_CLIENT_TEST_CLIENT_INTERNAL_EVHTTP_CONNECTION_H_
6 changes: 3 additions & 3 deletions net_http/client/test_client/public/httpclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef THIRD_PARTY_TENSORFLOW_SERVING_UTIL_NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_H_
#define THIRD_PARTY_TENSORFLOW_SERVING_UTIL_NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_H_
#ifndef NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_H_
#define NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_H_

#include "absl/memory/memory.h"
#include "net_http/client/test_client/internal/evhttp_connection.h"
Expand All @@ -40,5 +40,5 @@ inline std::unique_ptr<TestHTTPClientInterface> CreateEvHTTPConnection(

} // namespace net_http

#endif // THIRD_PARTY_TENSORFLOW_SERVING_UTIL_NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_H_
#endif // NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_H_

6 changes: 3 additions & 3 deletions net_http/client/test_client/public/httpclient_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef THIRD_PARTY_TENSORFLOW_SERVING_UTIL_NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_INTERFACE_H_
#define THIRD_PARTY_TENSORFLOW_SERVING_UTIL_NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_INTERFACE_H_
#ifndef NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_INTERFACE_H_
#define NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_INTERFACE_H_

#include "net_http/public/response_code_enum.h"
#include "net_http/server/public/httpserver_interface.h"
Expand Down Expand Up @@ -83,4 +83,4 @@ namespace net_http

} // namespace net_http

#endif // THIRD_PARTY_TENSORFLOW_SERVING_UTIL_NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_INTERFACE_H_
#endif // NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_INTERFACE_H_
6 changes: 3 additions & 3 deletions net_http/compression/gzip_zlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef TENSORFLOW_SERVING_UTIL_NET_HTTP_COMPRESSION_GZIP_ZLIB_H_
#define TENSORFLOW_SERVING_UTIL_NET_HTTP_COMPRESSION_GZIP_ZLIB_H_
#ifndef NET_HTTP_COMPRESSION_GZIP_ZLIB_H_
#define NET_HTTP_COMPRESSION_GZIP_ZLIB_H_

#include <zlib.h>

Expand Down Expand Up @@ -340,4 +340,4 @@ namespace net_http

} // namespace net_http

#endif // TENSORFLOW_SERVING_UTIL_NET_HTTP_COMPRESSION_GZIP_ZLIB_H_
#endif // NET_HTTP_COMPRESSION_GZIP_ZLIB_H_
6 changes: 3 additions & 3 deletions net_http/internal/fixed_thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef TENSORFLOW_SERVING_UTIL_NET_HTTP_INTERNAL_FIXED_THREAD_POOL_H_
#define TENSORFLOW_SERVING_UTIL_NET_HTTP_INTERNAL_FIXED_THREAD_POOL_H_
#ifndef NET_HTTP_INTERNAL_FIXED_THREAD_POOL_H_
#define NET_HTTP_INTERNAL_FIXED_THREAD_POOL_H_

#include <cassert>
#include <functional>
Expand Down Expand Up @@ -99,4 +99,4 @@ namespace net_http

} // namespace net_http

#endif // TENSORFLOW_SERVING_UTIL_NET_HTTP_INTERNAL_FIXED_THREAD_POOL_H_
#endif // NET_HTTP_INTERNAL_FIXED_THREAD_POOL_H_
6 changes: 3 additions & 3 deletions net_http/internal/net_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef TENSORFLOW_SERVING_UTIL_NET_HTTP_INTERNAL_NET_LOGGING_H_
#define TENSORFLOW_SERVING_UTIL_NET_HTTP_INTERNAL_NET_LOGGING_H_
#ifndef NET_HTTP_INTERNAL_NET_LOGGING_H_
#define NET_HTTP_INTERNAL_NET_LOGGING_H_

#include <string>

Expand Down Expand Up @@ -72,4 +72,4 @@ namespace net_http

} // namespace net_http

#endif // TENSORFLOW_SERVING_UTIL_NET_HTTP_INTERNAL_NET_LOGGING_H_
#endif // NET_HTTP_INTERNAL_NET_LOGGING_H_
6 changes: 3 additions & 3 deletions net_http/public/header_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef TENSORFLOW_SERVING_UTIL_NET_HTTP_PUBLIC_HEADER_NAMES_H_
#define TENSORFLOW_SERVING_UTIL_NET_HTTP_PUBLIC_HEADER_NAMES_H_
#ifndef NET_HTTP_PUBLIC_HEADER_NAMES_H_
#define NET_HTTP_PUBLIC_HEADER_NAMES_H_

namespace net_http {

Expand Down Expand Up @@ -178,4 +178,4 @@ class HTTPHeaders {

} // namespace net_http

#endif // TENSORFLOW_SERVING_UTIL_NET_HTTP_PUBLIC_HEADER_NAMES_H_
#endif // NET_HTTP_PUBLIC_HEADER_NAMES_H_
6 changes: 3 additions & 3 deletions net_http/public/response_code_enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#ifndef TENSORFLOW_SERVING_UTIL_NET_HTTP_PUBLIC_RESPONSE_CODE_ENUM_H_
#define TENSORFLOW_SERVING_UTIL_NET_HTTP_PUBLIC_RESPONSE_CODE_ENUM_H_
#ifndef NET_HTTP_PUBLIC_RESPONSE_CODE_ENUM_H_
#define NET_HTTP_PUBLIC_RESPONSE_CODE_ENUM_H_
namespace net_http {

enum class HTTPStatusCode {
Expand Down Expand Up @@ -105,4 +105,4 @@ enum class HTTPStatusCode {

} // namespace net_http

#endif // TENSORFLOW_SERVING_UTIL_NET_HTTP_PUBLIC_RESPONSE_CODE_ENUM_H_
#endif // NET_HTTP_PUBLIC_RESPONSE_CODE_ENUM_H_
6 changes: 3 additions & 3 deletions net_http/server/internal/evhttp_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ limitations under the License.

// libevent based request implementation

#ifndef TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_INTERNAL_EVHTTP_REQUEST_H_
#define TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_INTERNAL_EVHTTP_REQUEST_H_
#ifndef NET_HTTP_SERVER_INTERNAL_EVHTTP_REQUEST_H_
#define NET_HTTP_SERVER_INTERNAL_EVHTTP_REQUEST_H_

#include <cstdint>
#include <memory>
Expand Down Expand Up @@ -135,4 +135,4 @@ class EvHTTPRequest final : public ServerRequestInterface {

} // namespace net_http

#endif // TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_INTERNAL_EVHTTP_REQUEST_H_
#endif // NET_HTTP_SERVER_INTERNAL_EVHTTP_REQUEST_H_
6 changes: 3 additions & 3 deletions net_http/server/internal/evhttp_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ limitations under the License.

// libevent based server implementation

#ifndef TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_INTERNAL_EVHTTP_SERVER_H_
#define TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_INTERNAL_EVHTTP_SERVER_H_
#ifndef NET_HTTP_SERVER_INTERNAL_EVHTTP_SERVER_H_
#define NET_HTTP_SERVER_INTERNAL_EVHTTP_SERVER_H_

#include <cstdint>
#include <ctime>
Expand Down Expand Up @@ -136,4 +136,4 @@ class EvHTTPServer final : public HTTPServerInterface, ServerSupport {

} // namespace net_http

#endif // TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_INTERNAL_EVHTTP_SERVER_H_
#endif // NET_HTTP_SERVER_INTERNAL_EVHTTP_SERVER_H_
6 changes: 3 additions & 3 deletions net_http/server/internal/server_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ limitations under the License.
// server object so the two are properly decoupled.
// This may turn out to be generally useful with no libevents specifics.

#ifndef TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_INTERNAL_SERVER_SUPPORT_H_
#define TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_INTERNAL_SERVER_SUPPORT_H_
#ifndef NET_HTTP_SERVER_INTERNAL_SERVER_SUPPORT_H_
#define NET_HTTP_SERVER_INTERNAL_SERVER_SUPPORT_H_

#include <functional>

Expand Down Expand Up @@ -47,4 +47,4 @@ class ServerSupport {

} // namespace net_http

#endif // TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_INTERNAL_SERVER_SUPPORT_H_
#endif // NET_HTTP_SERVER_INTERNAL_SERVER_SUPPORT_H_
6 changes: 3 additions & 3 deletions net_http/server/public/httpserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ limitations under the License.

// The entry point to access different HTTP server implementations.

#ifndef TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_PUBLIC_HTTPSERVER_H_
#define TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_PUBLIC_HTTPSERVER_H_
#ifndef NET_HTTP_SERVER_PUBLIC_HTTPSERVER_H_
#define NET_HTTP_SERVER_PUBLIC_HTTPSERVER_H_

#include <memory>

Expand Down Expand Up @@ -45,4 +45,4 @@ inline std::unique_ptr<HTTPServerInterface> CreateEvHTTPServer(

} // namespace net_http

#endif // TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_PUBLIC_HTTPSERVER_H_
#endif // NET_HTTP_SERVER_PUBLIC_HTTPSERVER_H_
6 changes: 3 additions & 3 deletions net_http/server/public/httpserver_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ limitations under the License.

// APIs for the HTTP server.

#ifndef TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_PUBLIC_HTTPSERVER_INTERFACE_H_
#define TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_PUBLIC_HTTPSERVER_INTERFACE_H_
#ifndef NET_HTTP_SERVER_PUBLIC_HTTPSERVER_INTERFACE_H_
#define NET_HTTP_SERVER_PUBLIC_HTTPSERVER_INTERFACE_H_

#include <cassert>

Expand Down Expand Up @@ -199,4 +199,4 @@ class HTTPServerInterface {

} // namespace net_http

#endif // TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_PUBLIC_HTTPSERVER_INTERFACE_H_
#endif // NET_HTTP_SERVER_PUBLIC_HTTPSERVER_INTERFACE_H_
6 changes: 3 additions & 3 deletions net_http/server/public/server_request_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ limitations under the License.
// Streamed request/response APIs are to be added, which will introduce
// additional API contract wrt the threading semantics.

#ifndef TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_PUBLIC_SERVER_REQUEST_INTERFACE_H_
#define TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_PUBLIC_SERVER_REQUEST_INTERFACE_H_
#ifndef NET_HTTP_SERVER_PUBLIC_SERVER_REQUEST_INTERFACE_H_
#define NET_HTTP_SERVER_PUBLIC_SERVER_REQUEST_INTERFACE_H_

#include <cstdlib>
#include <functional>
Expand Down Expand Up @@ -204,4 +204,4 @@ inline void SetContentTypeTEXT(ServerRequestInterface* request) {

} // namespace net_http

#endif // TENSORFLOW_SERVING_UTIL_NET_HTTP_SERVER_PUBLIC_SERVER_REQUEST_INTERFACE_H_
#endif // NET_HTTP_SERVER_PUBLIC_SERVER_REQUEST_INTERFACE_H_