forked from dirtyharrycallahan/pystrace
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetNumOfTraceType.py
More file actions
39 lines (32 loc) · 947 Bytes
/
getNumOfTraceType.py
File metadata and controls
39 lines (32 loc) · 947 Bytes
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
import sys
import os
import glob
import csv
def Start():
#csv_list = "/home/ruimin/pystrace/csvdir/" # recursive=Tru
csv_list = "/home/ruimin/mollitiam/Result2/Apps_stand/"
syscall_dict = dict()
for root, dirs, csvfiles in os.walk(csv_list):
# print str(len(csvfiles))
for csvfile in csvfiles:
if csvfile[-4:] == ".csv":
# print csvfile
with open(os.path.join(root,csvfile), 'r') as csv_fd:
for line in csv_fd.readlines():
syscall = line.strip().split(',')[1]
print syscall[1:-1]
if not bool(syscall_dict.get(syscall)):
syscall_dict[syscall] = 1
else:
syscall_dict[syscall] += 1
with open('syscall_freq2.csv','wb') as f:
writer =csv.writer(f)
for key, value in syscall_dict.items():
writer.writerow([key,value])
print "syscall set length is " + str(len(syscall_dict))
print 'finished'
#
# Entry point to the application
#
if __name__ == '__main__':
Start()