File tree Expand file tree Collapse file tree 10 files changed +114
-1
lines changed Expand file tree Collapse file tree 10 files changed +114
-1
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,8 @@ void TimeLimitListener::onPostExecute() {
97
97
// TODO: run this just after child exit
98
98
auto time = getTimeUsage ();
99
99
outputBuilder_->setRealTimeMicroseconds (time->realTimeUs );
100
+ outputBuilder_->setUserTimeMicroseconds (time->processTimeUs .uTimeUs );
101
+ outputBuilder_->setSysTimeMicroseconds (time->processTimeUs .sTimeUs );
100
102
verifyTimeUsage (move (time));
101
103
}
102
104
Original file line number Diff line number Diff line change
1
+ #include " HumanReadableOIOutputBuilder.h"
2
+
3
+ #include < sstream>
4
+
5
+ namespace s2j {
6
+ namespace printer {
7
+
8
+ const std::string HumanReadableOIOutputBuilder::FORMAT_NAME = " human" ;
9
+
10
+ std::string HumanReadableOIOutputBuilder::dump () const {
11
+ KillReason reason = killReason_;
12
+ if (reason == KillReason::NONE) {
13
+ if (killSignal_ > 0 || exitStatus_ > 0 ) {
14
+ reason = KillReason::RE;
15
+ }
16
+ }
17
+
18
+ std::stringstream ss;
19
+ auto reasonName = killReasonName (reason);
20
+ // This is inspired by the oiejq script
21
+ ss << std::endl << " -------------------------" << std::endl << " Result: " ;
22
+ dumpStatus (ss);
23
+ ss << std::endl
24
+ << " Time used: " << milliSecondsElapsed_ / 1000 << " ."
25
+ << milliSecondsElapsed_ % 1000 << " s" << std::endl;
26
+ ss << " Memory used: " << memoryPeakKb_ / 1024 << " MiB" << std::endl;
27
+ return ss.str ();
28
+ }
29
+
30
+ } // namespace printer
31
+ } // namespace s2j
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include " OIModelOutputBuilder.h"
4
+
5
+ namespace s2j {
6
+ namespace printer {
7
+
8
+ class HumanReadableOIOutputBuilder : public OIModelOutputBuilder {
9
+ public:
10
+ std::string dump () const override ;
11
+
12
+ const static std::string FORMAT_NAME;
13
+ };
14
+
15
+ } // namespace printer
16
+ } // namespace s2j
Original file line number Diff line number Diff line change @@ -24,6 +24,16 @@ OutputBuilder& OIModelOutputBuilder::setRealTimeMicroseconds(uint64_t time) {
24
24
return *this ;
25
25
}
26
26
27
+ OutputBuilder& OIModelOutputBuilder::setUserTimeMicroseconds (uint64_t time) {
28
+ userMilliSecondsElapsed_ = time / 1000 ;
29
+ return *this ;
30
+ }
31
+
32
+ OutputBuilder& OIModelOutputBuilder::setSysTimeMicroseconds (uint64_t time) {
33
+ sysMilliSecondsElapsed_ = time / 1000 ;
34
+ return *this ;
35
+ }
36
+
27
37
OutputBuilder& OIModelOutputBuilder::setMemoryPeak (uint64_t memoryPeakKb) {
28
38
memoryPeakKb_ = memoryPeakKb;
29
39
return *this ;
Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ class OIModelOutputBuilder : public OutputBuilder {
13
13
14
14
OutputBuilder& setCyclesUsed (uint64_t cyclesUsed) override ;
15
15
OutputBuilder& setRealTimeMicroseconds (uint64_t time) override ;
16
+ OutputBuilder& setUserTimeMicroseconds (uint64_t time) override ;
17
+ OutputBuilder& setSysTimeMicroseconds (uint64_t time) override ;
16
18
OutputBuilder& setMemoryPeak (uint64_t memoryPeakKb) override ;
17
19
OutputBuilder& setExitStatus (uint32_t exitStatus) override ;
18
20
OutputBuilder& setKillSignal (uint32_t killSignal) override ;
@@ -24,6 +26,8 @@ class OIModelOutputBuilder : public OutputBuilder {
24
26
25
27
uint64_t milliSecondsElapsed_;
26
28
uint64_t realMilliSecondsElapsed_;
29
+ uint64_t userMilliSecondsElapsed_;
30
+ uint64_t sysMilliSecondsElapsed_;
27
31
uint64_t memoryPeakKb_;
28
32
uint64_t syscallsCounter_;
29
33
uint32_t exitStatus_;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ class OITimeToolOutputBuilder : public OIModelOutputBuilder {
11
11
12
12
const static std::string FORMAT_NAME;
13
13
14
- private :
14
+ protected :
15
15
int encodeStatusCode () const ;
16
16
};
17
17
Original file line number Diff line number Diff line change
1
+ #include " OITimeToolUserOutputBuilder.h"
2
+ #include " common/Exception.h"
3
+
4
+ #include < sstream>
5
+
6
+ namespace s2j {
7
+ namespace printer {
8
+
9
+ const std::string OITimeToolUserOutputBuilder::FORMAT_NAME = " oittuser" ;
10
+
11
+ std::string OITimeToolUserOutputBuilder::dump () const {
12
+ std::stringstream ss;
13
+ ss << " __RESULT__ " << encodeStatusCode () << " " << userMilliSecondsElapsed_
14
+ << " " << 0ULL << " " << memoryPeakKb_ << " " << syscallsCounter_
15
+ << std::endl;
16
+ dumpStatus (ss);
17
+ ss << std::endl;
18
+ return ss.str ();
19
+ }
20
+
21
+ } // namespace printer
22
+ } // namespace s2j
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include " OITimeToolOutputBuilder.h"
4
+
5
+ namespace s2j {
6
+ namespace printer {
7
+
8
+ class OITimeToolUserOutputBuilder : public OITimeToolOutputBuilder {
9
+ public:
10
+ std::string dump () const override ;
11
+
12
+ const static std::string FORMAT_NAME;
13
+ };
14
+
15
+ } // namespace printer
16
+ } // namespace s2j
Original file line number Diff line number Diff line change @@ -36,6 +36,12 @@ class OutputBuilder {
36
36
virtual OutputBuilder& setRealTimeMicroseconds (uint64_t time) {
37
37
return *this ;
38
38
}
39
+ virtual OutputBuilder& setUserTimeMicroseconds (uint64_t time) {
40
+ return *this ;
41
+ }
42
+ virtual OutputBuilder& setSysTimeMicroseconds (uint64_t time) {
43
+ return *this ;
44
+ }
39
45
virtual OutputBuilder& setMemoryPeak (uint64_t memoryPeakKb) {
40
46
return *this ;
41
47
}
Original file line number Diff line number Diff line change 4
4
5
5
#include " common/Utils.h"
6
6
#include " printer/AugmentedOIOutputBuilder.h"
7
+ #include " printer/HumanReadableOIOutputBuilder.h"
7
8
#include " printer/OITimeToolOutputBuilder.h"
9
+ #include " printer/OITimeToolUserOutputBuilder.h"
8
10
#include " printer/RealTimeOIOutputBuilder.h"
9
11
#include " seccomp/policy/DefaultPolicy.h"
10
12
#include " seccomp/policy/PermissivePolicy.h"
@@ -91,6 +93,10 @@ const FactoryMap<s2j::printer::OutputBuilder>
91
93
ApplicationSettings::OUTPUT_FORMATS (
92
94
{{" oitt" ,
93
95
std::make_shared<s2j::printer::OITimeToolOutputBuilder>},
96
+ {" oittuser" ,
97
+ std::make_shared<s2j::printer::OITimeToolUserOutputBuilder>},
98
+ {" human" ,
99
+ std::make_shared<s2j::printer::HumanReadableOIOutputBuilder>},
94
100
{" oiaug" ,
95
101
std::make_shared<s2j::printer::AugmentedOIOutputBuilder>},
96
102
{" oireal" ,
You can’t perform that action at this time.
0 commit comments