1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13 * express or implied.
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
17 */
18
19 #include "oscl_file_stats.h"
20 #include "oscl_tickcount.h"
21 #include "pvlogger.h"
22 #include "oscl_int64_utils.h"
23
OsclFileStats(Oscl_File * c)24 OsclFileStats::OsclFileStats(Oscl_File* c): iContainer(c)
25 {
26 oscl_memset(iStats, 0, sizeof(iStats));
27 }
28
Start(uint32 & aTicks)29 void OsclFileStats::Start(uint32& aTicks)
30 {
31 aTicks = OsclTickCount::TickCount();
32 }
33
End(TOsclFileOp aOp,uint32 aStart,uint32 aParam,TOsclFileOffset aParam2)34 void OsclFileStats::End(TOsclFileOp aOp, uint32 aStart, uint32 aParam, TOsclFileOffset aParam2)
35 {
36 uint32 delta = OsclTickCount::TickCount() - aStart;
37 if (iStats[aOp].iOpCount == 0
38 || delta > iStats[aOp].iTotalTicks)
39 {
40 iStats[aOp].iStartTick = aStart;
41 iStats[aOp].iTotalTicks = delta;
42 iStats[aOp].iParam = aParam;
43 iStats[aOp].iParam2 = aParam2;
44 }
45 iStats[aOp].iOpCount++;
46 }
47
48
Log(TOsclFileOp aOp,PVLogger * aLogger,uint32 aLogLevel)49 void OsclFileStats::Log(TOsclFileOp aOp, PVLogger* aLogger, uint32 aLogLevel)
50 {
51 OSCL_UNUSED_ARG(aOp);
52 OSCL_UNUSED_ARG(aLogLevel);
53 #if OSCL_HAS_LARGE_FILE_SUPPORT
54 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, aLogger, aLogLevel
55 , (0, "OsclFileStats(0x%x): Op %s Count %d, Max: Param %d, Param2 hi:0x%8x lo:0x%08x, StartTick %d TotalTick %d"
56 , iContainer, TOsclFileOpStr[aOp]
57 , iStats[aOp].iOpCount, iStats[aOp].iParam
58 , Oscl_Int64_Utils::get_int64_upper32((const int64)(iStats[aOp].iParam2))
59 , Oscl_Int64_Utils::get_int64_lower32((const int64)(iStats[aOp].iParam2))
60 , iStats[aOp].iStartTick, iStats[aOp].iTotalTicks
61 ));
62 #else
63 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, aLogger, aLogLevel
64 , (0, "OsclFileStats(0x%x): Op %s Count %d, Max: Param %d, Param2 %d, StartTick %d TotalTick %d"
65 , iContainer, TOsclFileOpStr[aOp]
66 , iStats[aOp].iOpCount, iStats[aOp].iParam
67 , iStats[aOp].iParam2
68 , iStats[aOp].iStartTick, iStats[aOp].iTotalTicks
69 ));
70 #endif
71 }
72
LogAll(PVLogger * aLogger,uint32 aLogLevel)73 void OsclFileStats::LogAll(PVLogger* aLogger, uint32 aLogLevel)
74 {
75 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, aLogger, aLogLevel
76 , (0, "OsclFileStats(0x%x): +++++++++++++++++++++ Begin", iContainer));
77 for (uint32 op = 0; op < EOsclFileOp_Last; op++)
78 {
79 if (iStats[op].iOpCount > 0)
80 {
81 Log((TOsclFileOp)op, aLogger, aLogLevel);
82 }
83 }
84 //clear all stats once they've been dumped.
85 oscl_memset(iStats, 0, sizeof(iStats));
86 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, aLogger, aLogLevel
87 , (0, "OsclFileStats(0x%x): +++++++++++++++++++++ End", iContainer));
88 }
89
90