4 ## Copyright (c) 2010-2017 Intel Corporation
6 ## Licensed under the Apache License, Version 2.0 (the "License");
7 ## you may not use this file except in compliance with the License.
8 ## You may obtain a copy of the License at
10 ## http://www.apache.org/licenses/LICENSE-2.0
12 ## Unless required by applicable law or agreed to in writing, software
13 ## distributed under the License is distributed on an "AS IS" BASIS,
14 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ## See the License for the specific language governing permissions and
16 ## limitations under the License.
19 from statsconsfile import *
22 class TSStatsConsFile:
23 def __init__(self, fileName, offset):
25 self.statsConsFile = StatsConsFile(fileName)
28 entry = self._readNextEntry();
32 while (entry is not None and entry[-1] <= 0):
33 entry = self._readNextEntry();
37 def _readNextEntry(self):
38 entry = self.statsConsFile.readNext();
47 for i in range(0, len(entry), 2):
49 created += entry[i][3]
52 last_tsc = entry[i][6]
54 last_tsc -= self.offset;
55 last_tsc = Decimal(last_tsc) / self.statsConsFile.getHz();
57 return [active, created, rx, tx, last_tsc];
60 self.statsConsFile.close();