修改代码加入pprof
|
|
生成性能报表
-
运行程序
-
生成内存性能报表
1go tool pprof ./apply_idem http://localhost:6060/debug/pprof/heap -
生成CPU性能报表
1234567891011121314151617181920212223242526272829303132333435363738394041424344go tool pprof ./apply_idem http://localhost:6060/debug/pprof/profileFetching profile over HTTP from http://localhost:6060/debug/pprof/profileSaved profile in /Users/loushuai/pprof/pprof.apply_idem.samples.cpu.001.pb.gzFile: apply_idemType: cpuTime: Apr 10, 2018 at 3:33pm (CST)Duration: 30.02s, Total samples = 2.55s ( 8.49%)Entering interactive mode (type "help" for commands, "o" for options)(pprof) list exec_on_source_for_one_rowTotal: 2.55sROUTINE ======================== main.exec_on_source_for_one_row in /Users/loushuai/dbscale/apply_script_go/apply_idem.go0 350ms (flat, cum) 13.73% of Total. . 225: return time_region_sql_snippet, time_region_sql_snippet_with_t. . 226:}. . 227:. . 228:func exec_on_source_for_one_row(query_sql string, column_count int) []string {. . 229: row := make([]string, column_count). 320ms 230: rows := exec_on_source(query_sql). . 231: defer rows.Close(). . 232: rawResult_onerow := make([][]byte, column_count). . 233: dest_onerow := make([]interface{}, column_count). . 234: for i, _ := range rawResult_onerow {. . 235: dest_onerow[i] = &rawResult_onerow[i]. . 236: }. . 237: for rows.Next() {. . 238: err := rows.Scan(dest_onerow...). . 239: if err != nil {. . 240: fatal_error(err.Error()). . 241: }. . 242: for i, raw := range rawResult_onerow {. . 243: if raw == nil {. . 244: row[i] = "\\N". . 245: } else {. 10ms 246: row[i] = string(raw). . 247: }. . 248: }. . 249: break. . 250: }. 20ms 251: return row. . 252:}. . 253:. . 254:func exec_on_target(query_sql string) {. . 255: retry_count := 10. . 256: if Print_msg { -
生成flumegraph
|
|