diff options
-rw-r--r-- | ydb/apps/ydb/CHANGELOG.md | 1 | ||||
-rw-r--r-- | ydb/public/lib/ydb_cli/commands/ydb_benchmark.cpp | 17 |
2 files changed, 17 insertions, 1 deletions
diff --git a/ydb/apps/ydb/CHANGELOG.md b/ydb/apps/ydb/CHANGELOG.md index 32415ea9ea5..461d69cd8a4 100644 --- a/ydb/apps/ydb/CHANGELOG.md +++ b/ydb/apps/ydb/CHANGELOG.md @@ -1,3 +1,4 @@ +* Added processing of special values `null`, `/dev/null`, `stdout`, `cout`, `console`, `stderr` and `cerr` of `--output` option in `ydb workload * run` command. * Fixed bug when `ydb wokrload` commands did not work with absolute paths. ## 2.22.1 ## diff --git a/ydb/public/lib/ydb_cli/commands/ydb_benchmark.cpp b/ydb/public/lib/ydb_cli/commands/ydb_benchmark.cpp index b0032d0eb9a..ae61a5ef13a 100644 --- a/ydb/public/lib/ydb_cli/commands/ydb_benchmark.cpp +++ b/ydb/public/lib/ydb_cli/commands/ydb_benchmark.cpp @@ -4,6 +4,7 @@ #include <ydb/public/lib/ydb_cli/common/plan2svg.h> #include <ydb/public/lib/ydb_cli/common/pretty_table.h> #include <library/cpp/json/json_writer.h> +#include <util/stream/null.h> #include <util/string/printf.h> #include <util/folder/path.h> #include <util/random/shuffle.h> @@ -456,7 +457,21 @@ int TWorkloadCommandBenchmark::RunBench(NYdbWorkload::IWorkloadQueryGenerator& w ui32 failsCount = 0; ui32 diffsCount = 0; std::optional<TString> prevResult; - TOFStream outFStream(TStringBuilder() << OutFilePath << "." << queryName << ".out"); + THolder<IOutputStream> outFStreamHolder; + IOutputStream& outFStream = [&]() -> IOutputStream& { + if (TSet<TString>{"cout", "stdout", "console"}.contains(OutFilePath)) { + return Cout; + } + if (TSet<TString>{"cerr", "stderr"}.contains(OutFilePath)) { + return Cerr; + } + if (TSet<TString>{"", "/dev/null", "null"}.contains(OutFilePath)) { + outFStreamHolder = MakeHolder<TNullOutput>(); + } else { + outFStreamHolder = MakeHolder<TOFStream>(TStringBuilder() << OutFilePath << "." << queryName << ".out"); + } + return *outFStreamHolder; + }(); for (const auto& iterExec: queryExec) { if (Threads > 0) { iterExec->PrintQueryHeader(); |