Home | History | Annotate | Download | only in doc
      1 <html><head><link href="https://code.jquery.com/ui/1.12.0/themes/smoothness/jquery-ui.css" type="text/css" rel="stylesheet"></link>
      2 <link href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" type="text/css" rel="stylesheet"></link>
      3 <script src="https://www.gstatic.com/charts/loader.js"></script>
      4 <script>google.charts.load('current', {'packages': ['corechart', 'table']});</script>
      5 <script src="https://code.jquery.com/jquery-3.2.1.js"></script>
      6 <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
      7 <script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
      8 <script src="https://cdn.datatables.net/1.10.16/js/dataTables.jqueryui.min.js"></script>
      9 <style type="text/css">
     10             .colForLine { width: 50px; }
     11             .colForCount { width: 100px; }
     12             .tableCell { font-size: 17px; }
     13             .boldTableCell { font-weight: bold; font-size: 17px; }
     14             </style>
     15 </head>
     16 <body><div id="report_content"></div>
     17 <script type="application/json" id="record_data">{"functionMap": {"0": {"d": [["", 0], ["binary_cache/data/app/com.example.simpleperf.simpleperfexamplewithnative-WWXaAz4Gfq1flZnVmLqwvg==/lib/arm64/libnative-lib.so:     file format elf64-littleaarch64", 0], ["", 0], ["", 0], ["Disassembly of section .text:", 0], ["", 0], ["00000000000075ec <RunFunction()>:", 0], ["_ZL11RunFunctionv():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:71", 0], ["    75ec:\tsub\tsp, sp, #0x50", 30188], ["    75f0:\tstp\tx22, x21, [sp,#32]", 30192], ["    75f4:\tstp\tx20, x19, [sp,#48]", 30196], ["    75f8:\tstp\tx29, x30, [sp,#64]", 30200], ["    75fc:\tadd\tx29, sp, #0x40", 30204], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:73", 0], ["    7600:\tmrs\tx19, tpidr_el0", 30208], ["    7604:\tldr\tx8, [x19,#40]", 30212], ["    7608:\tmov\tw22, #0xe100                \t// #57600", 30216], ["_ZL14GetSystemClockv():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:66", 0], ["    760c:\torr\tw0, wzr, #0x1", 30220], ["    7610:\tadd\tx1, sp, #0x8", 30224], ["_ZL11RunFunctionv():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:73", 0], ["    7614:\tstr\tx8, [sp,#24]", 30228], ["    7618:\tmovk\tw22, #0x5f5, lsl #16", 30232], ["_ZL14GetSystemClockv():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:66", 0], ["    761c:\tbl\t7020 <clock_gettime@plt>", 30236], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:67", 0], ["    7620:\tldp\tx21, x20, [sp,#8]", 30240], ["_ZL11RunFunctionv():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:73", 0], ["    7624:\tstr\twzr, [sp,#8]", 30244], ["    7628:\tb\t7638 <RunFunction()+0x4c>", 30248], ["    762c:\tldr\tw8, [sp,#8]", 30252], ["    7630:\tadd\tw8, w8, #0x1", 30256], ["    7634:\tstr\tw8, [sp,#8]", 30260], ["    7638:\tldr\tw8, [sp,#8]", 30264], ["    763c:\tcmp\tw8, w22", 30268], ["    7640:\tb.lt\t762c <RunFunction()+0x40>", 30272], ["_ZL14GetSystemClockv():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:66", 0], ["    7644:\torr\tw0, wzr, #0x1", 30276], ["    7648:\tadd\tx1, sp, #0x8", 30280], ["    764c:\tbl\t7020 <clock_gettime@plt>", 30284], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:67", 0], ["    7650:\tldp\tx9, x8, [sp,#8]", 30288], ["    7654:\tldr\tx10, [x19,#40]", 30292], ["    7658:\tldr\tx11, [sp,#24]", 30296], ["    765c:\tcmp\tx10, x11", 30300], ["    7660:\tb.ne\t768c <RunFunction()+0xa0>", 30304], ["_ZL11RunFunctionv():", 0], ["    7664:\tsub\tx9, x9, x21", 30308], ["_ZL14GetSystemClockv():", 0], ["    7668:\tsub\tx8, x8, x20", 30312], ["_ZL11RunFunctionv():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:75", 0], ["    766c:\tldp\tx29, x30, [sp,#64]", 30316], ["    7670:\tldp\tx20, x19, [sp,#48]", 30320], ["    7674:\tldp\tx22, x21, [sp,#32]", 30324], ["    7678:\tmov\tw10, #0xca00                \t// #51712", 30328], ["    767c:\tmovk\tw10, #0x3b9a, lsl #16", 30332], ["    7680:\tmadd\tx0, x9, x10, x8", 30336], ["    7684:\tadd\tsp, sp, #0x50", 30340], ["    7688:\tret", 30344], ["    768c:\tbl\t6d40 <__stack_chk_fail@plt>", 30348], ["", 0]], "s": [0, 71, 75], "l": 0, "f": "RunFunction()"}, "1": {"d": [["", 0], ["binary_cache/data/app/com.example.simpleperf.simpleperfexamplewithnative-WWXaAz4Gfq1flZnVmLqwvg==/lib/arm64/libnative-lib.so:     file format elf64-littleaarch64", 0], ["", 0], ["", 0], ["Disassembly of section .text:", 0], ["", 0], ["00000000000074dc <SleepThread(void*)>:", 0], ["_ZL11SleepThreadPv():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:87", 0], ["    74dc:\tstp\tx20, x19, [sp,#-32]!", 29916], ["    74e0:\tstp\tx29, x30, [sp,#16]", 29920], ["    74e4:\tadd\tx29, sp, #0x10", 29924], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:88", 0], ["    74e8:\tbl\t7000 <pthread_self@plt>", 29928], ["    74ec:\tadrp\tx1, 21000 <fde_mixed_encoding_compare+0x80>", 29932], ["    74f0:\tadd\tx1, x1, #0xd1c", 29936], ["    74f4:\tbl\t6db0 <pthread_setname_np@plt>", 29940], ["    74f8:\tmov\tx19, xzr", 29944], ["    74fc:\tmov\tx20, xzr", 29948], ["    7500:\tb\t750c <SleepThread(void*)+0x30>", 29952], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:94", 0], ["    7504:\tbl\t7690 <SleepFunction(unsigned long long)>", 29956], ["    7508:\tadd\tx19, x0, x19", 29960], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:92", 0], ["    750c:\tbl\t75ec <RunFunction()>", 29964], ["    7510:\tadd\tx20, x0, x20", 29968], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:93", 0], ["    7514:\tsubs\tx0, x20, x19", 29972], ["    7518:\tb.ls\t750c <SleepThread(void*)+0x30>", 29976], ["    751c:\tb\t7504 <SleepThread(void*)+0x28>", 29980], ["", 0]], "s": [0, 87, 93], "l": 0, "f": "SleepThread(void*)"}, "2": {"d": [["", 0], ["binary_cache/system/lib64/libc.so:     file format elf64-littleaarch64", 0], ["", 0], ["", 0], ["Disassembly of section .text:", 0], ["", 0], ["0000000000067d5c <__pthread_start(void*)>:", 0], ["_ZL15__pthread_startPv():", 0], ["   67d5c:\tstr\tx19, [sp,#-32]!", 425308], ["   67d60:\tstp\tx29, x30, [sp,#16]", 425312], ["   67d64:\tadd\tx29, sp, #0x10", 425316], ["   67d68:\tmov\tx19, x0", 425320], ["   67d6c:\tadd\tx0, x19, #0x80", 425324], ["   67d70:\tbl\t67c80 <Lock::lock()>", 425328], ["   67d74:\tmov\tx0, x19", 425332], ["   67d78:\tbl\t67650 <__init_alternate_signal_stack(pthread_internal_t*)>", 425336], ["   67d7c:\tldp\tx8, x0, [x19,#96]", 425340], ["   67d80:\tblr\tx8", 425344], ["   67d84:\tbl\t1a650 <pthread_exit@plt>", 425348], ["", 0]], "l": 1, "f": "__pthread_start(void*)"}, "3": {"d": [["", 0], ["binary_cache/system/lib64/libc.so:     file format elf64-littleaarch64", 0], ["", 0], ["", 0], ["Disassembly of section .text:", 0], ["", 0], ["000000000001ebd4 <__start_thread>:", 0], ["__start_thread():", 0], ["   1ebd4:\tstr\tx21, [sp,#-48]!", 125908], ["   1ebd8:\tstp\tx20, x19, [sp,#16]", 125912], ["   1ebdc:\tstp\tx29, x30, [sp,#32]", 125916], ["   1ebe0:\tadd\tx29, sp, #0x20", 125920], ["   1ebe4:\tmov\tx20, x1", 125924], ["   1ebe8:\tmrs\tx8, tpidr_el0", 125928], ["   1ebec:\tmov\tx19, x0", 125932], ["   1ebf0:\tcbz\tx8, 1ec14 <__start_thread+0x40>", 125936], ["   1ebf4:\tldr\tx21, [x8,#8]", 125940], ["   1ebf8:\tcbz\tx21, 1ec14 <__start_thread+0x40>", 125944], ["   1ebfc:\tldr\tw8, [x21,#16]", 125948], ["   1ec00:\tcmn\tw8, #0x1", 125952], ["   1ec04:\tb.ne\t1ec14 <__start_thread+0x40>", 125956], ["   1ec08:\tmov\tw0, #0xb2                  \t// #178", 125960], ["   1ec0c:\tbl\t18e20 <syscall@plt>", 125964], ["   1ec10:\tstr\tw0, [x21,#16]", 125968], ["   1ec14:\tmov\tx0, x20", 125972], ["   1ec18:\tblr\tx19", 125976], ["   1ec1c:\tbl\t6a47c <__exit>", 125980], ["", 0]], "l": 1, "f": "__start_thread"}, "4": {"d": [["", 0], ["binary_cache/system/lib64/libc.so:     file format elf64-littleaarch64", 0], ["", 0], ["", 0], ["Disassembly of section .text:", 0], ["", 0], ["000000000006ae6c <nanosleep>:", 0], ["nanosleep():", 0], ["   6ae6c:\tmov\tx8, #0x65                  \t// #101", 437868], ["   6ae70:\tsvc\t#0x0", 437872], ["   6ae74:\tcmn\tx0, #0x1, lsl #12", 437876], ["   6ae78:\tcneg\tx0, x0, hi", 437880], ["   6ae7c:\tb.hi\t1d6e0 <__set_errno_internal>", 437884], ["   6ae80:\tret", 437888], ["", 0]], "l": 1, "f": "nanosleep"}, "5": {"d": [["", 0], ["binary_cache/data/app/com.example.simpleperf.simpleperfexamplewithnative-WWXaAz4Gfq1flZnVmLqwvg==/lib/arm64/libnative-lib.so:     file format elf64-littleaarch64", 0], ["", 0], ["", 0], ["Disassembly of section .text:", 0], ["", 0], ["0000000000007690 <SleepFunction(unsigned long long)>:", 0], ["_ZL13SleepFunctiony():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:78", 0], ["    7690:\tsub\tsp, sp, #0x70", 30352], ["    7694:\tstr\tx23, [sp,#48]", 30356], ["    7698:\tstp\tx22, x21, [sp,#64]", 30360], ["    769c:\tstp\tx20, x19, [sp,#80]", 30364], ["    76a0:\tstp\tx29, x30, [sp,#96]", 30368], ["    76a4:\tadd\tx29, sp, #0x60", 30372], ["    76a8:\tmrs\tx23, tpidr_el0", 30376], ["    76ac:\tldr\tx8, [x23,#40]", 30380], ["    76b0:\tmov\tx19, x0", 30384], ["_ZL14GetSystemClockv():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:66", 0], ["    76b4:\torr\tw0, wzr, #0x1", 30388], ["    76b8:\tadd\tx1, sp, #0x18", 30392], ["    76bc:\tstr\tx8, [sp,#40]", 30396], ["    76c0:\tbl\t7020 <clock_gettime@plt>", 30400], ["_ZL13SleepFunctiony():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:81", 0], ["    76c4:\tmov\tx9, #0x5a53                \t// #23123", 30404], ["    76c8:\tmovk\tx9, #0xa09b, lsl #16", 30408], ["    76cc:\tmovk\tx9, #0xb82f, lsl #32", 30412], ["    76d0:\tlsr\tx8, x19, #9", 30416], ["    76d4:\tmovk\tx9, #0x44, lsl #48", 30420], ["_ZL14GetSystemClockv():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:67", 0], ["    76d8:\tldp\tx20, x21, [sp,#24]", 30424], ["    76dc:\tmov\tw22, #0xca00                \t// #51712", 30428], ["_ZL13SleepFunctiony():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:81", 0], ["    76e0:\tumulh\tx8, x8, x9", 30432], ["    76e4:\tmovk\tw22, #0x3b9a, lsl #16", 30436], ["    76e8:\tlsr\tx8, x8, #11", 30440], ["    76ec:\tstr\tx8, [sp,#8]", 30444], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:82", 0], ["    76f0:\tnop", 30448], ["    76f4:\tmsub\tx8, x8, x22, x19", 30452], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:83", 0], ["    76f8:\tadd\tx0, sp, #0x8", 30456], ["    76fc:\tmov\tx1, xzr", 30460], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:82", 0], ["    7700:\tstr\tx8, [sp,#16]", 30464], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:83", 0], ["    7704:\tbl\t6d80 <nanosleep@plt>", 30468], ["_ZL14GetSystemClockv():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:66", 0], ["    7708:\torr\tw0, wzr, #0x1", 30472], ["    770c:\tadd\tx1, sp, #0x18", 30476], ["    7710:\tbl\t7020 <clock_gettime@plt>", 30480], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:67", 0], ["    7714:\tldp\tx8, x9, [sp,#24]", 30484], ["    7718:\tldr\tx10, [x23,#40]", 30488], ["    771c:\tldr\tx11, [sp,#40]", 30492], ["    7720:\tcmp\tx10, x11", 30496], ["    7724:\tb.ne\t774c <SleepFunction(unsigned long long)+0xbc>", 30500], ["_ZL13SleepFunctiony():", 0], ["    7728:\tsub\tx8, x8, x20", 30504], ["_ZL14GetSystemClockv():", 0], ["    772c:\tsub\tx9, x9, x21", 30508], ["_ZL13SleepFunctiony():", 0], ["/ssd/android/aosp_master/system/extras/simpleperf/demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp:84", 0], ["    7730:\tmadd\tx0, x8, x22, x9", 30512], ["    7734:\tldp\tx29, x30, [sp,#96]", 30516], ["    7738:\tldp\tx20, x19, [sp,#80]", 30520], ["    773c:\tldp\tx22, x21, [sp,#64]", 30524], ["    7740:\tldr\tx23, [sp,#48]", 30528], ["    7744:\tadd\tsp, sp, #0x70", 30532], ["    7748:\tret", 30536], ["    774c:\tbl\t6d40 <__stack_chk_fail@plt>", 30540], ["", 0]], "s": [0, 78, 84], "l": 0, "f": "SleepFunction(unsigned long long)"}, "6": {"d": [["", 0], ["binary_cache/system/lib64/libc.so:     file format elf64-littleaarch64", 0], ["", 0], ["", 0], ["Disassembly of section .text:", 0], ["", 0], ["000000000001bbac <clock_gettime>:", 0], ["clock_gettime():", 0], ["   1bbac:\tadrp\tx8, cf000 <__libc_globals>", 113580], ["   1bbb0:\tadd\tx8, x8, #0x0", 113584], ["   1bbb4:\tldr\tx2, [x8,#8]", 113588], ["   1bbb8:\tcbz\tx2, 1bbc0 <clock_gettime+0x14>", 113592], ["   1bbbc:\tbr\tx2", 113596], ["   1bbc0:\tb\t6a434 <__clock_gettime>", 113600], ["", 0]], "l": 1, "f": "clock_gettime"}}, "sourceFiles": [{"path": "../demo/SimpleperfExampleWithNative/app/src/main/cpp/native-lib.cpp", "code": {"61": "    }\n", "62": "}\n", "63": "\n", "64": "static inline uint64_t GetSystemClock() {\n", "65": "    timespec ts;\n", "66": "    clock_gettime(CLOCK_MONOTONIC, &ts);\n", "67": "    return ts.tv_sec * 1000000000ULL + ts.tv_nsec;\n", "68": "}\n", "69": "\n", "70": "constexpr int LOOP_COUNT = 100000000;\n", "71": "static uint64_t noinline RunFunction() {\n", "72": "    uint64_t start_time_in_ns = GetSystemClock();\n", "73": "    for (volatile int i = 0; i < LOOP_COUNT; ++i) {\n", "74": "    }\n", "75": "    return GetSystemClock() - start_time_in_ns;\n", "76": "}\n", "77": "\n", "78": "static uint64_t noinline SleepFunction(unsigned long long sleep_time_in_ns) {\n", "79": "    uint64_t start_time_in_ns = GetSystemClock();\n", "80": "    struct timespec req;\n", "81": "    req.tv_sec = sleep_time_in_ns / 1000000000;\n", "82": "    req.tv_nsec = sleep_time_in_ns % 1000000000;\n", "83": "    nanosleep(&req, nullptr);\n", "84": "    return GetSystemClock() - start_time_in_ns;\n", "85": "}\n", "86": "\n", "87": "static void* SleepThread(void*) {\n", "88": "    pthread_setname_np(pthread_self(), \"SleepThread\");\n", "89": "    uint64_t total_sleep_time_in_ns = 0;\n", "90": "    uint64_t total_run_time_in_ns = 0;\n", "91": "    while (true) {\n", "92": "        total_run_time_in_ns += RunFunction();\n", "93": "        if (total_sleep_time_in_ns < total_run_time_in_ns) {\n", "94": "            total_sleep_time_in_ns += SleepFunction(total_run_time_in_ns - total_sleep_time_in_ns);\n", "95": "        }\n", "96": "    }\n", "97": "}\n", "98": "\n", "99": "extern \"C\"\n"}}], "machineType": "Pixel 2 (walleye) by Google, arch aarch64", "recordTime": "2017-11-08 (Wednesday) 17:35:07", "recordCmdline": "/data/local/tmp/simpleperf record -g -e task-clock:u --trace-offcpu -f 1000 --duration 10 -o /data/local/tmp/perf.data --app com.example.simpleperf.simpleperfexamplewithnative", "libList": ["/data/app/com.example.simpleperf.simpleperfexamplewithnative-WWXaAz4Gfq1flZnVmLqwvg==/lib/arm64/libnative-lib.so", "/system/lib64/libc.so"], "totalSamples": 5257, "processNames": {"25581": ""}, "sampleInfo": [{"eventName": "task-clock:u", "processes": [{"threads": [{"tid": 25593, "libs": [{"functions": [{"a": [{"a": 30256, "s": 985646356, "e": 985646356}, {"a": 30264, "s": 3018068989, "e": 3018068989}, {"a": 30272, "s": 1022339983, "e": 1022339983}], "c": 5238, "rg": {"s": 5026055328, "e": 0, "c": [{"s": 5026055328, "e": 0, "c": [{"s": 5026055328, "e": 0, "c": [{"s": 5026055328, "e": 5026055328, "c": [], "f": 3}], "f": 2}], "f": 1}], "f": 0}, "s": [{"s": 5026055328, "e": 5026055328, "l": 73, "f": 0}], "g": {"s": 5026055328, "e": 5026055328, "c": [], "f": 0}}, {"a": [{"a": 29956, "s": 4991492255, "e": 0}, {"a": 29964, "s": 5026055328, "e": 0}], "c": 0, "rg": {"s": 10017547583, "e": 0, "c": [{"s": 10017547583, "e": 0, "c": [{"s": 10017547583, "e": 10017547583, "c": [], "f": 3}], "f": 2}], "f": 1}, "s": [{"s": 4991492255, "e": 0, "l": 94, "f": 0}, {"s": 5026055328, "e": 0, "l": 92, "f": 0}], "g": {"s": 10017547583, "e": 0, "c": [{"s": 5026055328, "e": 5026055328, "c": [], "f": 0}, {"s": 4991492255, "e": 0, "c": [{"s": 4990502255, "e": 4990502255, "c": [], "f": 4}], "f": 5}], "f": 1}}, {"a": [{"a": 30468, "s": 4990502255, "e": 0}, {"a": 30480, "s": 990000, "e": 0}], "c": 0, "rg": {"s": 4991492255, "e": 0, "c": [{"s": 4991492255, "e": 0, "c": [{"s": 4991492255, "e": 0, "c": [{"s": 4991492255, "e": 4991492255, "c": [], "f": 3}], "f": 2}], "f": 1}], "f": 5}, "s": [{"s": 4990502255, "e": 0, "l": 83, "f": 0}, {"s": 990000, "e": 0, "l": 66, "f": 0}, {"s": 990000, "e": 0, "l": 84, "f": 0}], "g": {"s": 4991492255, "e": 0, "c": [{"s": 4990502255, "e": 4990502255, "c": [], "f": 4}, {"s": 990000, "e": 990000, "c": [], "f": 6}], "f": 5}}], "libId": 0, "eventCount": 5026055328}, {"functions": [{"a": [{"a": 425344, "s": 10017547583, "e": 0}], "c": 0, "rg": {"s": 10017547583, "e": 0, "c": [{"s": 10017547583, "e": 10017547583, "c": [], "f": 3}], "f": 2}, "g": {"s": 10017547583, "e": 0, "c": [{"s": 10017547583, "e": 0, "c": [{"s": 5026055328, "e": 5026055328, "c": [], "f": 0}, {"s": 4991492255, "e": 0, "c": [{"s": 4990502255, "e": 4990502255, "c": [], "f": 4}], "f": 5}], "f": 1}], "f": 2}}, {"a": [{"a": 125976, "s": 10017547583, "e": 0}], "c": 0, "rg": {"s": 10017547583, "e": 10017547583, "c": [], "f": 3}, "g": {"s": 10017547583, "e": 0, "c": [{"s": 10017547583, "e": 0, "c": [{"s": 10017547583, "e": 0, "c": [{"s": 5026055328, "e": 5026055328, "c": [], "f": 0}, {"s": 4991492255, "e": 0, "c": [{"s": 4990502255, "e": 4990502255, "c": [], "f": 4}], "f": 5}], "f": 1}], "f": 2}], "f": 3}}, {"a": [{"a": 437876, "s": 4990502255, "e": 4990502255}], "c": 18, "rg": {"s": 4990502255, "e": 0, "c": [{"s": 4990502255, "e": 0, "c": [{"s": 4990502255, "e": 0, "c": [{"s": 4990502255, "e": 0, "c": [{"s": 4990502255, "e": 4990502255, "c": [], "f": 3}], "f": 2}], "f": 1}], "f": 5}], "f": 4}, "g": {"s": 4990502255, "e": 4990502255, "c": [], "f": 4}}], "libId": 1, "eventCount": 4991492255}], "eventCount": 10017547583}], "pid": 25581, "eventCount": 10017547583}], "eventCount": 10017547583}], "threadNames": {"25593": "SleepThread"}, "androidVersion": "8.1.0"}</script>
     18 <script>/*
     19  * Copyright (C) 2017 The Android Open Source Project
     20  *
     21  * Licensed under the Apache License, Version 2.0 (the "License");
     22  * you may not use this file except in compliance with the License.
     23  * You may obtain a copy of the License at
     24  *
     25  *      http://www.apache.org/licenses/LICENSE-2.0
     26  *
     27  * Unless required by applicable law or agreed to in writing, software
     28  * distributed under the License is distributed on an "AS IS" BASIS,
     29  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     30  * See the License for the specific language governing permissions and
     31  * limitations under the License.
     32  */
     33 'use strict';
     34 
     35 // Use IIFE to avoid leaking names to other scripts.
     36 $(document).ready(function() {
     37 
     38 function openHtml(name, attrs={}) {
     39     let s = `<${name} `;
     40     for (let key in attrs) {
     41         s += `${key}="${attrs[key]}" `;
     42     }
     43     s += '>';
     44     return s;
     45 }
     46 
     47 function closeHtml(name) {
     48     return `</${name}>`;
     49 }
     50 
     51 function getHtml(name, attrs={}) {
     52     let text;
     53     if ('text' in attrs) {
     54         text = attrs.text;
     55         delete attrs.text;
     56     }
     57     let s = openHtml(name, attrs);
     58     if (text) {
     59         s += text;
     60     }
     61     s += closeHtml(name);
     62     return s;
     63 }
     64 
     65 function getTableRow(cols, colName, attrs={}) {
     66     let s = openHtml('tr', attrs);
     67     for (let col of cols) {
     68         s += `<${colName}>${col}</${colName}>`;
     69     }
     70     s += '</tr>';
     71     return s;
     72 }
     73 
     74 function toPercentageStr(percentage) {
     75     return percentage.toFixed(2) + '%';
     76 }
     77 
     78 function getProcessName(pid) {
     79     let name = gProcesses[pid];
     80     return name ? `${pid} (${name})`: pid.toString();
     81 }
     82 
     83 function getThreadName(tid) {
     84     let name = gThreads[tid];
     85     return name ? `${tid} (${name})`: tid.toString();
     86 }
     87 
     88 function getLibName(libId) {
     89     return gLibList[libId];
     90 }
     91 
     92 function getFuncName(funcId) {
     93     return gFunctionMap[funcId].f;
     94 }
     95 
     96 function getLibNameOfFunction(funcId) {
     97     return getLibName(gFunctionMap[funcId].l);
     98 }
     99 
    100 function getFuncSourceRange(funcId) {
    101     let func = gFunctionMap[funcId];
    102     if (func.hasOwnProperty('s')) {
    103         return {fileId: func.s[0], startLine: func.s[1], endLine: func.s[2]};
    104     }
    105     return null;
    106 }
    107 
    108 function getFuncDisassembly(funcId) {
    109     let func = gFunctionMap[funcId];
    110     return func.hasOwnProperty('d') ? func.d : null;
    111 }
    112 
    113 function getSourceFilePath(sourceFileId) {
    114     return gSourceFiles[sourceFileId].path;
    115 }
    116 
    117 function getSourceCode(sourceFileId) {
    118     return gSourceFiles[sourceFileId].code;
    119 }
    120 
    121 function isClockEvent(eventInfo) {
    122     return eventInfo.eventName.includes('task-clock') ||
    123             eventInfo.eventName.includes('cpu-clock');
    124 }
    125 
    126 class TabManager {
    127     constructor(divContainer) {
    128         this.div = $('<div>', {id: 'tabs'});
    129         this.div.appendTo(divContainer);
    130         this.div.append(getHtml('ul'));
    131         this.tabs = [];
    132         this.isDrawCalled = false;
    133     }
    134 
    135     addTab(title, tabObj) {
    136         let id = 'tab_' + this.div.children().length;
    137         let tabDiv = $('<div>', {id: id});
    138         tabDiv.appendTo(this.div);
    139         this.div.children().first().append(
    140             getHtml('li', {text: getHtml('a', {href: '#' + id, text: title})}));
    141         tabObj.init(tabDiv);
    142         this.tabs.push(tabObj);
    143         if (this.isDrawCalled) {
    144             this.div.tabs('refresh');
    145         }
    146         return tabObj;
    147     }
    148 
    149     findTab(title) {
    150         let links = this.div.find('li a');
    151         for (let i = 0; i < links.length; ++i) {
    152             if (links.eq(i).text() == title) {
    153                 return this.tabs[i];
    154             }
    155         }
    156         return null;
    157     }
    158 
    159     draw() {
    160         this.div.tabs({
    161             active: 0,
    162         });
    163         this.tabs.forEach(function(tab) {
    164             tab.draw();
    165         });
    166         this.isDrawCalled = true;
    167     }
    168 
    169     setActive(tabObj) {
    170         for (let i = 0; i < this.tabs.length; ++i) {
    171             if (this.tabs[i] == tabObj) {
    172                 this.div.tabs('option', 'active', i);
    173                 break;
    174             }
    175         }
    176     }
    177 }
    178 
    179 // Show global information retrieved from the record file, including:
    180 //   record time
    181 //   machine type
    182 //   Android version
    183 //   record cmdline
    184 //   total samples
    185 class RecordFileView {
    186     constructor(divContainer) {
    187         this.div = $('<div>');
    188         this.div.appendTo(divContainer);
    189     }
    190 
    191     draw() {
    192         google.charts.setOnLoadCallback(() => this.realDraw());
    193     }
    194 
    195     realDraw() {
    196         this.div.empty();
    197         // Draw a table of 'Name', 'Value'.
    198         let rows = [];
    199         if (gRecordInfo.recordTime) {
    200             rows.push(['Record Time', gRecordInfo.recordTime]);
    201         }
    202         if (gRecordInfo.machineType) {
    203             rows.push(['Machine Type', gRecordInfo.machineType]);
    204         }
    205         if (gRecordInfo.androidVersion) {
    206             rows.push(['Android Version', gRecordInfo.androidVersion]);
    207         }
    208         if (gRecordInfo.recordCmdline) {
    209             rows.push(['Record cmdline', gRecordInfo.recordCmdline]);
    210         }
    211         rows.push(['Total Samples', '' + gRecordInfo.totalSamples]);
    212 
    213         let data = new google.visualization.DataTable();
    214         data.addColumn('string', '');
    215         data.addColumn('string', '');
    216         data.addRows(rows);
    217         for (let i = 0; i < rows.length; ++i) {
    218             data.setProperty(i, 0, 'className', 'boldTableCell');
    219         }
    220         let table = new google.visualization.Table(this.div.get(0));
    221         table.draw(data, {
    222             width: '100%',
    223             sort: 'disable',
    224             allowHtml: true,
    225             cssClassNames: {
    226                 'tableCell': 'tableCell',
    227             },
    228         });
    229     }
    230 }
    231 
    232 // Show pieChart of event count percentage of each process, thread, library and function.
    233 class ChartView {
    234     constructor(divContainer, eventInfo) {
    235         this.id = divContainer.children().length;
    236         this.div = $('
', {id: 'chartstat_' + this.id}); 237 this.div.appendTo(divContainer); 238 this.eventInfo = eventInfo; 239 this.processInfo = null; 240 this.threadInfo = null; 241 this.libInfo = null; 242 this.states = { 243 SHOW_EVENT_INFO: 1, 244 SHOW_PROCESS_INFO: 2, 245 SHOW_THREAD_INFO: 3, 246 SHOW_LIB_INFO: 4, 247 }; 248 if (isClockEvent(this.eventInfo)) { 249 this.getSampleWeight = function (eventCount) { 250 return (eventCount / 1000000.0).toFixed(3) + ' ms'; 251 } 252 } else { 253 this.getSampleWeight = (eventCount) => '' + eventCount; 254 } 255 } 256 257 _getState() { 258 if (this.libInfo) { 259 return this.states.SHOW_LIB_INFO; 260 } 261 if (this.threadInfo) { 262 return this.states.SHOW_THREAD_INFO; 263 } 264 if (this.processInfo) { 265 return this.states.SHOW_PROCESS_INFO; 266 } 267 return this.states.SHOW_EVENT_INFO; 268 } 269 270 _goBack() { 271 let state = this._getState(); 272 if (state == this.states.SHOW_PROCESS_INFO) { 273 this.processInfo = null; 274 } else if (state == this.states.SHOW_THREAD_INFO) { 275 this.threadInfo = null; 276 } else if (state == this.states.SHOW_LIB_INFO) { 277 this.libInfo = null; 278 } 279 this.draw(); 280 } 281 282 _selectHandler(chart) { 283 let selectedItem = chart.getSelection()[0]; 284 if (selectedItem) { 285 let state = this._getState(); 286 if (state == this.states.SHOW_EVENT_INFO) { 287 this.processInfo = this.eventInfo.processes[selectedItem.row]; 288 } else if (state == this.states.SHOW_PROCESS_INFO) { 289 this.threadInfo = this.processInfo.threads[selectedItem.row]; 290 } else if (state == this.states.SHOW_THREAD_INFO) { 291 this.libInfo = this.threadInfo.libs[selectedItem.row]; 292 } 293 this.draw(); 294 } 295 } 296 297 draw() { 298 google.charts.setOnLoadCallback(() => this.realDraw()); 299 } 300 301 realDraw() { 302 this.div.empty(); 303 this._drawTitle(); 304 this._drawPieChart(); 305 } 306 307 _drawTitle() { 308 // Draw a table of 'Name', 'Event Count'. 309 let rows = []; 310 rows.push(['Event Type: ' + this.eventInfo.eventName, 311 this.getSampleWeight(this.eventInfo.eventCount)]); 312 if (this.processInfo) { 313 rows.push(['Process: ' + getProcessName(this.processInfo.pid), 314 this.getSampleWeight(this.processInfo.eventCount)]); 315 } 316 if (this.threadInfo) { 317 rows.push(['Thread: ' + getThreadName(this.threadInfo.tid), 318 this.getSampleWeight(this.threadInfo.eventCount)]); 319 } 320 if (this.libInfo) { 321 rows.push(['Library: ' + getLibName(this.libInfo.libId), 322 this.getSampleWeight(this.libInfo.eventCount)]); 323 } 324 let data = new google.visualization.DataTable(); 325 data.addColumn('string', ''); 326 data.addColumn('string', ''); 327 data.addRows(rows); 328 for (let i = 0; i < rows.length; ++i) { 329 data.setProperty(i, 0, 'className', 'boldTableCell'); 330 } 331 let wrapperDiv = $('
'); 332 wrapperDiv.appendTo(this.div); 333 let table = new google.visualization.Table(wrapperDiv.get(0)); 334 table.draw(data, { 335 width: '100%', 336 sort: 'disable', 337 allowHtml: true, 338 cssClassNames: { 339 'tableCell': 'tableCell', 340 }, 341 }); 342 if (this._getState() != this.states.SHOW_EVENT_INFO) { 343 let button = $('