profile 的结果是个文本信息,例如
.....
0.075 0.0 30496.312 40.2 1 _decode_one_frame (image.obj)
0.075 0.0 0.142 0.0 236 _readSyntaxElement_FLC (vlc.obj)
0.070 0.0 38.906 0.1 40 _get_mem4Dshort (memalloc.obj)
0.068 0.0 0.068 0.0 39 _decode_poc (header.obj)
0.067 0.0 0.067 0.0 236 _GetBits (vlc.obj)
......
这些信息是有规律的,我把类似的信息保存在文本文件中,起名为result.txt,打开Excel,进入Visual Basic编辑器,编写VBA代码,如下:
Dim s As String
' 执行函数入口
Public Sub Analyse()
filespec = "C:/result.txt" '按实际路径填写
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, str
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(filespec)
Set ts = f.OpenAsTextStream(ForReading, TristateFalse)
s = ts.ReadLine
j = 1
While s <> ""
i = 1
While s <> ""
str = Chr(Asc("A") + i - 1) & CStr(j)
wd = GetWord()
If wd <> "" Then
Range(str) = wd
End If
i = i + 1
Wend
If Not ts.AtEndOfStream Then
s = ts.ReadLine
Else
s = ""
End If
j = j + 1
Wend
ts.Close
End Sub
'从字符串读取词
Public Function GetWord() As String
i = 1
While (Mid(s, i, 1) = " " And Mid(s, i, 1) <> "")
i = i + 1
Wend
While (Mid(s, i, 1) <> " " And Mid(s, i, 1) <> "")
GetWord = GetWord & Mid(s, i, 1)
i = i + 1
Wend
If Len(s) - i > 0 Then
s = Right(s, Len(s) - i)
Else
s = ""
End If
End Function
匆匆写就,比较笨的方法,请行家批评指正