-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
pcscd_perfs.py
executable file
·62 lines (50 loc) · 2.19 KB
/
pcscd_perfs.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
# pcscd_perfs.py: calculate the cumulative times of pcscd logs
# Copyright (C) 2010 Ludovic Rousseau
"""
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Usage:
# 1. start pcscd in debug mode to generate a trace
# pcscd --foreground --debug
# 2. copy the trace into a file using Copy/Paste of your terminal
# 3. Make sure the first line of the log file is the first output line
# 00000000 debuglog.c:277:DebugLogSetLevel() debug level=debug
# 4. run the script
# ./pcscd_perfs.py log
# Log file:
# 00000000 debuglog.c:277:DebugLogSetLevel() debug level=debug
# 00000316 configfile.l:242:DBGetReaderListDir() Parsing conf directory: /etc/reader.conf.d
# 00000029 configfile.l:284:DBGetReaderList() Parsing conf file: /etc/reader.conf.d/0comments
# Output:
# 00000000 00000000 debuglog.c:277:DebugLogSetLevel() debug level=debug
# 00000316 00000316 configfile.l:242:DBGetReaderListDir() Parsing conf directory: /etc/reader.conf.d
# 00000345 00000029 configfile.l:284:DBGetReaderList() Parsing conf file: /etc/reader.conf.d/0comments
# The first column is the cumulative time in µs i.e. the sum of the
# second column
def total_time(file):
total = 0
for line in open(file).readlines():
fields = line.split(' ')
delta = fields[0]
# user entered a Ctrl-C
if delta.startswith('\x03'):
return
total += int(delta)
print("%08d" % total, line, end='')
if __name__ == "__main__":
import sys
total_time(sys.argv[1])