脚本目录
1、脚本目录
D:\Android\SDK\ndk\21.4.7075529\simpleperf
2、在此目录中右键"在终端中打开"
3、输入命令
python app_profiler.py -p xxxx.android.launcher
PS D:\Android\SDK\ndk\21.4.7075529\simpleperf> python app_profiler.py -p xxx.android.launcher
INFO:root:prepare profiling
INFO:root:start profiling
INFO:root:run adb cmd: ['adb', 'shell', '/data/local/tmp/simpleperf', 'record', '-o', '/data/local/tmp/perf.data', '-e task-clock:u -f 1000 -g --duration 10', '--log', 'info', '--app', 'xxxx.android.launcher']
....
INFO:root:profiling is finished.
4、.data转 html
python report_html.py
......
INFO:root:Report generated at 'report.html'.
5、这个时候转的report.html打不开的,需要修改一些内容
打开html文件
生成的html替换前:
<html><head><link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css"></link>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css"></link>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<script>google.charts.load('current', {'packages': ['corechart', 'table']});</script>
<style type="text/css">
.colForLine { width: 50px; }
.colForCount { width: 100px; }
.tableCell { font-size: 17px; }
.boldTableCell { font-weight: bold; font-size: 17px; }
</style>
</head>
<body><script>
替换后:
<html><head><link rel="stylesheet" type="text/css" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.1.2/css/bootstrap.min.css"></link>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css"></link>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.1.2/js/bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<script>google.charts.load('current', {'packages': ['corechart', 'table']});</script>
<style type="text/css">
.colForLine { width: 50px; }
.colForCount { width: 100px; }
.tableCell { font-size: 17px; }
.boldTableCell { font-weight: bold; font-size: 17px; }
</style>
</head>
<body><script>
6、重新打开report.html 就可以看到界面了