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 SutStatsConsFile:
23 def __init__(self, fileName, offset):
25 self.statsConsFile = StatsConsFile(fileName)
28 entry = self._readNextEntry();
33 while (entry is not None and entry[-1] <= 0):
34 entry = self._readNextEntry();
38 return self.statsConsFile.getHz();
40 def _readNextEntry(self):
41 entry = self.statsConsFile.readNext();
50 for i in range(0, len(entry), 2):
54 last_tsc = entry[i][5]
56 last_tsc -= self.offset;
57 last_tsc = Decimal(last_tsc) / self.statsConsFile.getHz();
58 return [rx, tx, drop, last_tsc];
61 self.statsConsFile.close();