e2e-examples/gcs/benchmark/runner_watcher.h (49 lines of code) (raw):
// Copyright 2022 gRPC authors.
//
// 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.
#ifndef GCS_BENCHMARK_RUNNER_WATCHER_H_
#define GCS_BENCHMARK_RUNNER_WATCHER_H_
#include <grpcpp/impl/codegen/status.h>
#include <string>
#include <vector>
#include "absl/synchronization/mutex.h"
#include "absl/time/time.h"
#include "parameters.h"
class RunnerWatcher {
public:
struct Chunk {
absl::Time time;
int64_t bytes;
};
struct Operation {
OperationType type;
int32_t runner_id;
int64_t channel_id;
std::string peer;
std::string bucket;
std::string object;
grpc::Status status;
int64_t bytes;
absl::Time time;
absl::Duration elapsed_time;
std::vector<Chunk> chunks;
};
public:
RunnerWatcher(size_t warmups = 0, bool verbose = false);
absl::Time GetStartTime() const;
void SetStartTime(absl::Time start_time);
absl::Duration GetDuration() const;
void SetDuration(absl::Duration duration);
void NotifyCompleted(OperationType operationType, int32_t runner_id,
int64_t channel_id, std::string peer, std::string bucket,
std::string object, grpc::Status status, int64_t bytes,
absl::Time time, absl::Duration elapsed_time,
std::vector<Chunk> chunks);
std::vector<Operation> GetNonWarmupsOperations() const;
absl::Duration GetNonWarmupsDuration() const;
private:
size_t warmups_;
bool verbose_;
absl::Time start_time_;
absl::Duration duration_;
std::vector<Operation> operations_;
mutable absl::Mutex lock_;
};
#endif // GCS_BENCHMARK_RUNNER_WATCHER_H_