腳本目錄
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轉(zhuǎn) html
python report_html.py
......
INFO:root:Report generated at 'report.html'.
5、這個時候轉(zhuǎn)的report.html打不開的,需要修改一些內(nèi)容
打開html文件
生成的html替換前:
<html><head><link rel="stylesheet" type="text/css" ></link>
<link rel="stylesheet" type="text/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" ></link>
<link rel="stylesheet" type="text/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 就可以看到界面了