@@ -15,16 +15,28 @@ namespace NKqpRun {
15
15
16
16
namespace {
17
17
18
+ // Function adds thousands separators
19
+ // 123456789 -> 123.456.789
18
20
TString FormatNumber (i64 number) {
21
+ struct TSeparator : public std ::numpunct<char > {
22
+ char do_thousands_sep () const final {
23
+ return ' .' ;
24
+ }
25
+
26
+ std::string do_grouping () const final {
27
+ return " \03 " ;
28
+ }
29
+ };
30
+
19
31
std::ostringstream stream;
20
- stream.imbue (std::locale (" en_US.UTF-8 " ));
32
+ stream.imbue (std::locale (stream. getloc (), new TSeparator () ));
21
33
stream << number;
22
34
return stream.str ();
23
35
}
24
36
25
- void PrintStatistic (const TString& fullStatistic , const THashMap<TString, i64>& flatStatistic , const NFq::TPublicStat& publicStatistic , IOutputStream& output) {
37
+ void PrintStatistics (const TString& fullStat , const THashMap<TString, i64>& flatStat , const NFq::TPublicStat& publicStat , IOutputStream& output) {
26
38
output << " \n Flat statistic:" << Endl;
27
- for (const auto & [propery, value] : flatStatistic ) {
39
+ for (const auto & [propery, value] : flatStat ) {
28
40
TString valueString = ToString (value);
29
41
if (propery.find (" Bytes" ) != TString::npos || propery.find (" Source" ) != TString::npos) {
30
42
valueString = NKikimr::NBlobDepot::FormatByteSize (value);
@@ -39,31 +51,31 @@ void PrintStatistic(const TString& fullStatistic, const THashMap<TString, i64>&
39
51
}
40
52
41
53
output << " \n Public statistic:" << Endl;
42
- if (auto memoryUsageBytes = publicStatistic .MemoryUsageBytes ) {
54
+ if (auto memoryUsageBytes = publicStat .MemoryUsageBytes ) {
43
55
output << " MemoryUsage = " << NKikimr::NBlobDepot::FormatByteSize (*memoryUsageBytes) << Endl;
44
56
}
45
- if (auto cpuUsageUs = publicStatistic .CpuUsageUs ) {
57
+ if (auto cpuUsageUs = publicStat .CpuUsageUs ) {
46
58
output << " CpuUsage = " << NFq::FormatDurationUs (*cpuUsageUs) << Endl;
47
59
}
48
- if (auto inputBytes = publicStatistic .InputBytes ) {
60
+ if (auto inputBytes = publicStat .InputBytes ) {
49
61
output << " InputSize = " << NKikimr::NBlobDepot::FormatByteSize (*inputBytes) << Endl;
50
62
}
51
- if (auto outputBytes = publicStatistic .OutputBytes ) {
63
+ if (auto outputBytes = publicStat .OutputBytes ) {
52
64
output << " OutputSize = " << NKikimr::NBlobDepot::FormatByteSize (*outputBytes) << Endl;
53
65
}
54
- if (auto sourceInputRecords = publicStatistic .SourceInputRecords ) {
66
+ if (auto sourceInputRecords = publicStat .SourceInputRecords ) {
55
67
output << " SourceInputRecords = " << FormatNumber (*sourceInputRecords) << Endl;
56
68
}
57
- if (auto sinkOutputRecords = publicStatistic .SinkOutputRecords ) {
69
+ if (auto sinkOutputRecords = publicStat .SinkOutputRecords ) {
58
70
output << " SinkOutputRecords = " << FormatNumber (*sinkOutputRecords) << Endl;
59
71
}
60
- if (auto runningTasks = publicStatistic .RunningTasks ) {
72
+ if (auto runningTasks = publicStat .RunningTasks ) {
61
73
output << " RunningTasks = " << FormatNumber (*runningTasks) << Endl;
62
74
}
63
75
64
76
output << " \n Full statistic:" << Endl;
65
77
NJson::TJsonValue statsJson;
66
- NJson::ReadJsonTree (fullStatistic , &statsJson);
78
+ NJson::ReadJsonTree (fullStat , &statsJson);
67
79
NJson::WriteJson (&output, &statsJson, true , true , true );
68
80
output << Endl;
69
81
}
@@ -282,26 +294,25 @@ class TKqpRunner::TImpl {
282
294
}
283
295
284
296
void PrintScriptProgress (const TString& plan) const {
285
- if (Options_.InProgressStatisticOutputFile ) {
286
- TFileOutput outputStream (*Options_.InProgressStatisticOutputFile );
287
- outputStream << TInstant::Now ().ToIsoStringLocal () << " Script in progress statistic " << Endl;
297
+ if (Options_.InProgressStatisticsOutputFile ) {
298
+ TFileOutput outputStream (*Options_.InProgressStatisticsOutputFile );
299
+ outputStream << TInstant::Now ().ToIsoStringLocal () << " Script in progress statistics " << Endl;
288
300
289
301
auto convertedPlan = plan;
290
302
try {
291
303
convertedPlan = StatProcessor_->ConvertPlan (plan);
292
- } catch (const NJson::TJsonException& ex) {
304
+ } catch (const NJson::TJsonException& ex) {
293
305
outputStream << " Error plan conversion: " << ex.what () << Endl;
294
306
}
295
307
296
308
try {
297
309
double cpuUsage = 0.0 ;
298
- auto stat = StatProcessor_->GetQueryStat (convertedPlan, cpuUsage);
299
- outputStream << " \n CPU usage: " << cpuUsage << Endl;
300
-
310
+ auto fullStat = StatProcessor_->GetQueryStat (convertedPlan, cpuUsage);
301
311
auto flatStat = StatProcessor_->GetFlatStat (convertedPlan);
302
- auto publicStat = StatProcessor_->GetPublicStat (stat );
312
+ auto publicStat = StatProcessor_->GetPublicStat (fullStat );
303
313
304
- PrintStatistic (stat, flatStat, publicStat, outputStream);
314
+ outputStream << " \n CPU usage: " << cpuUsage << Endl;
315
+ PrintStatistics (fullStat, flatStat, publicStat, outputStream);
305
316
} catch (const NJson::TJsonException& ex) {
306
317
outputStream << " Error stat conversion: " << ex.what () << Endl;
307
318
}
0 commit comments