使用gprofile收集性能数据

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
Created on 2013-6-22

@author: luoyulong
import os

def filterFiles(folder, exts):
    def anyTrue(predicate, sequence):
        return True in map(predicate, sequence)
    r=[]
    for fileName in os.listdir(folder):
        if os.path.isdir(folder + '/' + fileName):
            filterFiles(folder + '/' + fileName, exts)
        elif anyTrue(fileName.endswith, exts):
                r.append(fileName)
    return r


exts = ['.txt']
funs =['ICT::CMPM::UpdateStressCell']
funs.append('ICT::CMPM::EdgeMomentum')
funs.append('_ZN3ICT4CMPM13ComputingCellEPNS_3MPM    5CCellEb.clone.2')
funs.append('ICT::CMPM::EdgeMomentum')
funs.append('ICT::CMPM::UpdateMPV')


os.popen("rm ./Result.txt")

files=filterFiles(os.getcwd(), exts)
for fun in funs:
    records=[]
    for file in files:
        s=os.popen("grep "+fun+" ./"+file).read()
        x=s.split()
        if(len(x)>1):
            y=x[1].split('%')
            records.append(y[0])
    os.popen("echo "+fun+">> Result.txt")
    os.popen("echo "+str(len(records))+" "+">> Result.txt")
    for r in records:
        os.popen("echo "+r+">> Result.txt")

`