• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "taskmanager/task_statistics/task_statistics.h"
17 
18 namespace panda::taskmanager {
19 
TaskStatistics()20 TaskStatistics::TaskStatistics()
21 {
22     for (TaskType taskType : ALL_TASK_TYPES) {
23         for (VMType vmType : ALL_VM_TYPES) {
24             for (TaskExecutionMode executionMode : ALL_TASK_EXECUTION_MODES) {
25                 allTaskProperties_.emplace_back(taskType, vmType, executionMode);
26             }
27         }
28     }
29 }
30 
operator <<(std::ostream & os,TaskStatisticsImplType type)31 std::ostream &operator<<(std::ostream &os, TaskStatisticsImplType type)
32 {
33     switch (type) {
34         case TaskStatisticsImplType::FINE_GRAINED:
35             os << "TaskStatisticsImplType::FINE_GRAINED";
36             break;
37         case TaskStatisticsImplType::SIMPLE:
38             os << "TaskStatisticsImplType::SIMPLE";
39             break;
40         case TaskStatisticsImplType::LOCK_FREE:
41             os << "TaskStatisticsImplType::LOCK_FREE";
42             break;
43         default:
44             UNREACHABLE();
45     }
46     return os;
47 }
48 
TaskStatisticsImplTypeFromString(std::string_view string)49 TaskStatisticsImplType TaskStatisticsImplTypeFromString(std::string_view string)
50 {
51     if (string == "simple") {
52         return TaskStatisticsImplType::SIMPLE;
53     }
54     if (string == "fine-grained") {
55         return TaskStatisticsImplType::FINE_GRAINED;
56     }
57     if (string == "lock-free") {
58         return TaskStatisticsImplType::LOCK_FREE;
59     }
60     UNREACHABLE();
61 }
62 
63 }  // namespace panda::taskmanager
64