1. jdk 6u4之后可用-XX:+PrintGCDateStamps参数
2.python转换脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 |
#!/usr/bin/env python import
sys, os, datetime # true if string is a positive float def validSeconds(str_sec): try : return
0 < float (str_sec) except
ValueError: return
False # show usage if len (sys.argv) < 2 : print
"Usage: %s <gc.log>" %
(sys.argv[ 0 ]) sys.exit( 1 ) file_str =
sys.argv[ 1 ] lastmod_date =
datetime.datetime.fromtimestamp(os.path.getmtime(file_str)) file
= open (file_str, ‘r‘ ) lines =
file .readlines() file .close() # get last elapsed time for
line in
reversed (lines): parts =
line.split( ‘:‘ ) if
validSeconds(parts[ 0 ]): break # calculate start time start_date =
lastmod_date -
datetime.timedelta(seconds = float (parts[ 0 ])) # print file prepending human readable time where appropiate for
line in
lines: parts =
line.split( ‘:‘ ) if
not validSeconds(parts[ 0 ]): print
line.rstrip() continue line_date =
start_date +
datetime.timedelta(seconds = float (parts[ 0 ])) print
"%s: %s" % (line_date.isoformat(), line.rstrip()) |
原文:http://www.cnblogs.com/aiguang/p/3564177.html