minitrace
=========
by Henrik Rydgård 2014 (hrydgard+minitrace@gmail.com)
MIT licensed, feel free to use however you want. If you use it for something cool, I'd love to hear about it!
This is a C library with C++ helpers for producing JSON traces suitable for Chrome's excellent built-in trace viewer (chrome://tracing).
Extremely simple to build and use. Tested on Mac and Windows, but should compile anywhere you can use ANSI C with few or no changes.
Sample output (see example code below):
![minitrace](http://www.ppsspp.org/img/minitrace.png)
Remember to be careful when interpreting the output. This is not a sampling profiler, so it only records start and stop times for blocks. This means that blocks grow even when the CPU is off running another thread, and that it can look like work is being done on more blocks at a time than you have CPUs.
How to use
----------
1. Include minitrace.c and minitrace.h in your project. #include minitrace.h in some common header.
2. In your initialization code:
mtr_init("trace.json");
3. In your exit code:
mtr_shutdown();
4. In all functions you want to profile:
// C
MTR_BEGIN("GFX", "RasterizeTriangle")
...
MTR_END("GFX", "RasterizeTriangle")
// C++
MTR_SCOPE("GFX", "RasterizeTriangle")
5. In Google Chrome open "about:tracing"
6. Click Open, and choose your trace.json
7. Navigate the trace view using the WASD keys, and Look for bottlenecks and optimize your application.
8. In your final release build, build with
-DMTR_DISABLE
By default, it will collect 1 million tracepoints and then stop. You can change this behaviour, see the
top of the header file.
Note: Please only use string literals in MTR statements.
Example code
------------
int main(int argc, const char *argv[]) {
int i;
mtr_init("trace.json");
MTR_META_PROCESS_NAME("minitrace_test");
MTR_META_THREAD_NAME("main thread");
int long_running_thing_1;
int long_running_thing_2;
MTR_START("background", "long_running", &long_running_thing_1);
MTR_START("background", "long_running", &long_running_thing_2);
MTR_BEGIN("main", "outer");
usleep(80000);
for (i = 0; i < 3; i++) {
MTR_BEGIN("main", "inner");
usleep(40000);
MTR_END("main", "inner");
usleep(10000);
}
MTR_STEP("background", "long_running", &long_running_thing_1, "middle step");
usleep(80000);
MTR_END("main", "outer");
usleep(50000);
MTR_INSTANT("main", "the end");
usleep(10000);
MTR_FINISH("background", "long_running", &long_running_thing_1);
MTR_FINISH("background", "long_running", &long_running_thing_2);
mtr_flush();
mtr_shutdown();
return 0;
}
The output will result in something looking a little like the picture at the top of this readme.
Future plans:
* Builtin background flush thread support with better synchronization, no more fixed limit
* Support for more trace arguments, more tracing types
If you use this, feel free to tell me how, and what issues you may have had. hrydgard+minitrace@gmail.com
没有合适的资源?快使用搜索试试~ 我知道了~
2019华为云鲲鹏开发者大赛决赛冠军---电饭煲火锅战队.zip
共156个文件
h:71个
cpp:47个
txt:9个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 98 浏览量
2023-10-23
10:11:21
上传
评论
收藏 890KB ZIP 举报
温馨提示
2019华为云鲲鹏开发者大赛决赛冠军---电饭煲火锅战队.zip
资源推荐
资源详情
资源评论
收起资源包目录
2019华为云鲲鹏开发者大赛决赛冠军---电饭煲火锅战队.zip (156个子文件)
cJSON.c 23KB
log.cc 6KB
tinyxml2.cpp 69KB
xml_parsing.cpp 25KB
game.cpp 16KB
parse_message.cpp 13KB
OSSocket.cpp 11KB
minitrace.cpp 9KB
main.cpp 7KB
bt_factory.cpp 7KB
basic_types.cpp 7KB
action_node.cpp 6KB
tree_node.cpp 4KB
action_eat_enemy.cpp 4KB
parallel_node.cpp 4KB
behavior_tree.cpp 4KB
action_explore_map.cpp 4KB
action_search_enemy.cpp 4KB
action_eat_power.cpp 3KB
action_run_away.cpp 3KB
make_decision.cpp 3KB
timeout_node.cpp 3KB
sequence_node.cpp 3KB
sequence_star_node.cpp 3KB
fallback_node.cpp 3KB
repeat_node.cpp 3KB
retry_node.cpp 3KB
decorator_node.cpp 3KB
reactive_sequence.cpp 2KB
reactive_fallback.cpp 2KB
blackboard.cpp 2KB
control_node.cpp 2KB
inverter_node.cpp 2KB
bt_file_logger.cpp 2KB
shared_library_UNIX.cpp 2KB
example.cpp 2KB
condition_node.cpp 2KB
action_out_vision.cpp 2KB
bt_minitrace_logger.cpp 2KB
shared_library_WIN.cpp 1KB
action_avoid_enemy.cpp 1KB
bt_cout_logger.cpp 1KB
assign_task.cpp 1KB
player.cpp 1KB
action_remove_invalid.cpp 1KB
shared_library.cpp 639B
test.cpp 565B
subtree_node.cpp 459B
predict_enemy.cpp 192B
2019华为云鲲鹏开发者大赛·决赛试题文档.docx 175KB
ai_yang.exe 518KB
BT_logger.fbs 1KB
.gitignore 6KB
flatbuffers.h 93KB
flatbuffers.h 93KB
tinyxml2.h 67KB
BT_logger_generated.h 24KB
util.h 23KB
util.h 22KB
base.h 12KB
base.h 12KB
bt_factory.h 11KB
minitrace.h 11KB
coroutine.h 10KB
path.h 10KB
tree_node.h 9KB
basic_types.h 9KB
stl_emulation.h 9KB
timer_queue.h 7KB
cJSON.h 7KB
bt_flatbuffer_helper.h 6KB
blackboard.h 6KB
action_node.h 5KB
shared_library.h 5KB
OSSocket.h 4KB
behavior_tree.h 4KB
blackboard_precondition.h 3KB
data.h 3KB
game.h 3KB
condition_node.h 3KB
abstract_logger.h 2KB
player.h 2KB
set_blackboard_node.h 2KB
exceptions.h 2KB
retry_node.h 2KB
repeat_node.h 2KB
sequence_star_node.h 2KB
force_failure_node.h 2KB
force_success_node.h 2KB
sequence_node.h 2KB
resolver.h 2KB
control_node.h 2KB
demangle_util.h 2KB
parallel_node.h 2KB
reactive_fallback.h 2KB
fallback_node.h 2KB
reactive_sequence.h 2KB
inverter_node.h 2KB
always_success_node.h 2KB
always_failure_node.h 2KB
共 156 条
- 1
- 2
资源评论
天天501
- 粉丝: 552
- 资源: 4666
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功