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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 1、该资源包括项目的全部源码,下载可以直接使用! 2、本项目适合作为计算机、数学、电子信息等专业的竞赛项目学习资料,作为参考学习借鉴。 3、本资源作为“参考资料”如果需要实现其他功能,需要能看懂代码,并且热爱钻研,自行调试。 2019华为云鲲鹏开发者大赛决赛参赛源码+学习说明(冠军).zip ## 赛事简要 基于华为云自主创新的鲲鹏云服务器,选手进行主题为“化鲲为鹏”的游戏策略开发:根据大赛组织方提供的地图和元素,通过代码编程的方式操纵角色(赤鲲或蓝鲲)在地图上移动,获取积分。 ## 策略 策略部分见[strategy](doc/strategy.md)和[答辩PPT](doc/决赛答辩.pdf)。 ## 编译打包 直接CMake编译,Windows和Linux均兼容。 提供Windows版本[ai.exe](doc/ai_yang.exe),可以在线下和ai PK。
资源推荐
资源详情
资源评论
收起资源包目录
2019华为云鲲鹏开发者大赛决赛参赛源码+学习说明(冠军).zip (155个子文件)
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
共 155 条
- 1
- 2
资源评论
土豆片片
- 粉丝: 1852
- 资源: 5869
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功