Skip to content

Commit 1351ac1

Browse files
committedMar 15, 2017
Update the struct ProfileData
1 parent f1e37e7 commit 1351ac1

File tree

8 files changed

+54
-58
lines changed

8 files changed

+54
-58
lines changed
 

‎BehaviorTree/include/behavior_tree.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#pragma once
2-
#ifndef BEHAVIOR_TREE_H
3-
#define BEHAVIOR_TREE_H
4-
5-
#include "global.h"
6-
7-
void InitModule(const char *module_name);
8-
9-
#endif // !BEHAVIOR_TREE_H
1+
#pragma once
2+
#ifndef BEHAVIOR_TREE_H
3+
#define BEHAVIOR_TREE_H
4+
5+
#include "global.h"
6+
7+
void InitModule(const char *module_name);
8+
9+
#endif // !BEHAVIOR_TREE_H

‎BehaviorTree/include/node_data.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#pragma once
2-
#ifndef NODE_DATA_H
3-
#define NODE_DATA_H
4-
5-
struct NodeData {
6-
NodeData() : child_index(0) {}
7-
8-
size_t child_index;
9-
};
10-
11-
#endif // !NODE_DATA_H
1+
#pragma once
2+
#ifndef NODE_DATA_H
3+
#define NODE_DATA_H
4+
5+
struct NodeData {
6+
NodeData() : child_index(0) {}
7+
8+
size_t child_index;
9+
};
10+
11+
#endif // !NODE_DATA_H

‎BehaviorTree/include/profile/profile_data.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <ctime>
66

77
struct ProfileData {
8-
unsigned int times;
8+
unsigned int calls;
99
unsigned long clocks;
1010
};
1111

‎BehaviorTree/include/profile/profiler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Profiler {
2626
void AddProfileData(NodeId node_id, clock_t consumed_clocks) {
2727
if (!current_collection_) return;
2828
ProfileData &data = (*current_collection_)[node_id];
29-
++data.times;
29+
++data.calls;
3030
data.clocks += consumed_clocks;
3131
}
3232

‎BehaviorTree/src/behavior_tree.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ static PyObject *DumpProfileInPyDictObject() {
102102
PyObject *py_node_id = Py_BuildValue("i", inner_pair.first);
103103
PyObject *py_data = PyDict_New();
104104

105-
PyObject *py_times = Py_BuildValue("I", inner_pair.second.times);
106-
PyDict_SetItemString(py_data, "times", py_times);
107-
Py_DECREF(py_times);
105+
PyObject *py_calls = Py_BuildValue("I", inner_pair.second.calls);
106+
PyDict_SetItemString(py_data, "calls", py_calls);
107+
Py_DECREF(py_calls);
108108

109109
PyObject *py_clocks = Py_BuildValue("k", inner_pair.second.clocks);
110110
PyDict_SetItemString(py_data, "clocks", py_clocks);

‎BehaviorTree/src/global.cc

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#include "global.h"
2-
#include <ctime>
3-
4-
void get_timestamp(char *buffer, size_t size) {
5-
time_t timestamp = time(NULL);
6-
struct tm *time_info = localtime(&timestamp);
7-
strftime(buffer, sizeof(char *) * size, "%Y-%m-%d %H:%M:%S", time_info);
8-
}
1+
#include "global.h"
2+
#include <ctime>
3+
4+
void get_timestamp(char *buffer, size_t size) {
5+
time_t timestamp = time(NULL);
6+
struct tm *time_info = localtime(&timestamp);
7+
strftime(buffer, sizeof(char *) * size, "%Y-%m-%d %H:%M:%S", time_info);
8+
}

‎BehaviorTree/src/main.cc

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
#include "global.h"
2-
#include "behavior_tree.h"
3-
4-
#if defined(_DEBUG) | defined(TRACE_TICK)
5-
#define MODULE_NAME "behavior_tree_d"
6-
#else
7-
#define MODULE_NAME "behavior_tree"
8-
#endif
9-
10-
PyMODINIT_FUNC
11-
#if defined(_DEBUG) | defined(TRACE_TICK)
12-
initbehavior_tree_d() {
13-
PyErr_Warn(PyExc_RuntimeWarning, "This is the debug build of behavior_tree module!");
14-
#else
15-
initbehavior_tree() {
16-
#endif
17-
18-
InitModule(MODULE_NAME);
19-
}
1+
#include "global.h"
2+
#include "behavior_tree.h"
3+
4+
#if defined(_DEBUG) | defined(TRACE_TICK)
5+
#define MODULE_NAME "behavior_tree_d"
6+
#else
7+
#define MODULE_NAME "behavior_tree"
8+
#endif
9+
10+
PyMODINIT_FUNC
11+
#if defined(_DEBUG) | defined(TRACE_TICK)
12+
initbehavior_tree_d() {
13+
PyErr_Warn(PyExc_RuntimeWarning, "This is the debug build of behavior_tree module!");
14+
#else
15+
initbehavior_tree() {
16+
#endif
17+
18+
InitModule(MODULE_NAME);
19+
}

‎CMakeLists.txt

+2-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ include_directories(
2121

2222
add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
2323

24-
if(MSVC)
25-
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /D TRACE_TICK /D PROFILE_TICK")
26-
else(MSVC)
27-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
28-
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DTRACE_TICK -DPROFILE_TICK")
29-
endif(MSVC)
24+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
25+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DTRACE_TICK -DPROFILE_TICK")
3026

3127
set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "_d")
3228
set_target_properties(${PROJECT_NAME} PROPERTIES RELWITHDEBINFO_POSTFIX "_d")

0 commit comments

Comments
 (0)
Please sign in to comment.