Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

229 lines
6.9 KiB

  1. Option Explicit
  2. Function GetOneTokenFromString(SrcString)
  3. Dim OneToken As String
  4. Dim Pos As Integer
  5. Pos = InStr(SrcString, " ")
  6. If (Pos > 0) Then
  7. OneToken = Left(SrcString, Pos - 1)
  8. SrcString = Mid(SrcString, Pos + 1)
  9. GetOneTokenFromString = OneToken
  10. Else
  11. GetOneTokenFromString = SrcString
  12. SrcString = ""
  13. End If
  14. End Function
  15. Function GetOneToken(FileNumber)
  16. Dim OneToken As String
  17. Dim OneChar
  18. Do While Not EOF(FileNumber)
  19. OneChar = Input(1, FileNumber)
  20. If (OneChar = " ") Then
  21. GetOneToken = OneToken
  22. Exit Function
  23. Else
  24. OneToken = OneToken & OneChar
  25. End If
  26. Loop
  27. GetOneToken = OneToken
  28. End Function
  29. Function GetOneLine(FileNumber)
  30. Dim OneLine As String
  31. Input #FileNumber, OneLine
  32. GetOneLine = OneLine
  33. End Function
  34. Sub ProcessFile(FileName, TotalAspHits, TotalPPHits, TotalPPBytesRcved, AvgAspTime, AvgPPTime)
  35. On Error Resume Next
  36. Dim OneLine As String
  37. Dim OneToken As String
  38. Dim ByteRcved As Long
  39. Dim ByteSent As Long
  40. Dim TimeProcessed As Long
  41. Dim AspTimeProcessed As Long
  42. Dim RecvBytesIndex, TimeIndex, UrlIndex
  43. Dim I
  44. Dim bAsp As Boolean
  45. Dim bPrinter As Boolean
  46. TotalAspHits = 0
  47. TotalPPHits = 0
  48. ByteRcved = 0
  49. ByteSent = 0
  50. TimeProcessed = 0
  51. AspTimeProcessed = 0
  52. Open FileName For Input As #1
  53. If Err.Number Then
  54. Exit Sub
  55. End If
  56. Do While Not EOF(1)
  57. OneLine = GetOneLine(1)
  58. If Left(OneLine, 1) = "#" Then
  59. If Left(OneLine, 8) = "#Fields:" Then
  60. OneToken = GetOneTokenFromString(OneLine)
  61. I = 0
  62. Do While OneToken <> ""
  63. OneToken = GetOneTokenFromString(OneLine)
  64. Select Case OneToken
  65. Case "cs-uri-stem"
  66. UrlIndex = I
  67. Case "cs-bytes"
  68. RecvBytesIndex = I
  69. Case "time-taken"
  70. TimeIndex = I
  71. Case Else
  72. End Select
  73. I = I + 1
  74. Loop
  75. End If
  76. Else
  77. I = 0
  78. bAsp = False
  79. bPrinter = False
  80. Do While I = 0 Or OneToken <> ""
  81. OneToken = GetOneTokenFromString(OneLine)
  82. If I = UrlIndex Then
  83. 'Process the URL
  84. Const strPrn = "/.printer"
  85. Const strPrns = "printers"
  86. Const strAsp = ".asp"
  87. If Right(OneToken, Len(strPrn)) = strPrn Then
  88. bPrinter = True
  89. TotalPPHits = TotalPPHits + 1
  90. ElseIf Left(OneToken, Len(strPrns)) = strPrns And Right(OneToken, Len(strAsp)) = strAsp Then
  91. bPrinter = True
  92. TotalAspHits = TotalAspHits + 1
  93. End If
  94. End If
  95. If bAsp Then
  96. If I = TimeIndex Then
  97. AspTimeProcessed = AspTimeProcessed + Val(OneToken)
  98. End If
  99. End If
  100. If bPrinter Then
  101. If I = RecvBytesIndex Then
  102. ByteRcved = ByteRcved + Val(OneToken)
  103. End If
  104. If I = TimeIndex Then
  105. TimeProcessed = TimeProcessed + Val(OneToken)
  106. End If
  107. End If
  108. I = I + 1
  109. Loop
  110. End If
  111. Loop
  112. Close #1
  113. If TotalAspHits > 0 Then
  114. AvgAspTime = AspTimeProcessed / TotalAspHits
  115. End If
  116. If ByteRcved > 0 Then
  117. AvgPPTime = TimeProcessed / ByteRcved
  118. End If
  119. TotalPPBytesRcved = ByteRcved
  120. End Sub
  121. Private Sub Command1_Click()
  122. End
  123. End Sub
  124. Private Sub FileNameOK_Click()
  125. Dim MyDate As String * 300
  126. Dim MyTime As String * 9
  127. Dim MyString As String
  128. Dim FileName As String
  129. Dim TotalAspHits, TotalPPHits
  130. Dim AvgAspTime As Double
  131. Dim AvgPPTime As Double
  132. Dim TotalPPBytesRcved As Long
  133. Dim strEol As String
  134. Dim args, argc
  135. args = GetCommandLine()
  136. If UBound(args) >= 1 Then
  137. Form1.Text1 = args(1)
  138. End If
  139. 'FileName = "d:\public\ex980207.log"
  140. FileName = Form1.Text1
  141. 'FileName = "d:\public\ex" & Form1.YearTxt & Form1.MonthTxt & Form1.DayTxt & ".log"
  142. Call ProcessFile(FileName, TotalAspHits, TotalPPHits, TotalPPBytesRcved, AvgAspTime, AvgPPTime)
  143. strEol = Chr$(13) & Chr$(10)
  144. Result.Text = "Total .printer Hits = " & TotalPPHits & strEol
  145. Result.Text = Result.Text & "Total Bytes Printed = " & TotalPPBytesRcved & strEol
  146. Result.Text = Result.Text & "Total ASP Hits = " & TotalAspHits & strEol
  147. Result.Text = Result.Text & "Avg Asp Time (msec/hit) = " & Format(AvgAspTime, "###0.00") & strEol
  148. Result.Text = Result.Text & "Avg PP Time (msec/byte) = " & Format(AvgPPTime, "###0.00") & strEol
  149. 'Result.Text
  150. Debug.Print "Total .printer Hits = " & TotalPPHits
  151. Debug.Print "Total Bytes Printed = " & TotalPPBytesRcved
  152. Debug.Print "Avg Asp Time (msec/hit) = "; AvgAspTime
  153. Debug.Print "Avg PP Time (msec/byte) = "; AvgPPTime
  154. Debug.Print "Total ASP Hits = " & TotalAspHits
  155. Debug.Print "Total .printer Hits = " & TotalPPHits
  156. Debug.Print "Total Bytes Printed = " & TotalPPBytesRcved
  157. Debug.Print "Avg Asp Time (msec/hit) = "; AvgAspTime
  158. Debug.Print "Avg PP Time (msec/byte) = "; AvgPPTime
  159. End Sub
  160. Private Sub Form_Load()
  161. Call FileNameOK_Click
  162. End Sub
  163. Function GetCommandLine(Optional MaxArgs)
  164. 'Declare variables.
  165. Dim C, CmdLine, CmdLnLen, InArg, I, NumArgs
  166. 'See if MaxArgs was provided.
  167. If IsMissing(MaxArgs) Then MaxArgs = 10
  168. 'Make array of the correct size.
  169. ReDim ArgArray(MaxArgs)
  170. NumArgs = 0: InArg = False
  171. 'Get command line arguments.
  172. CmdLine = Command()
  173. CmdLnLen = Len(CmdLine)
  174. 'Go thru command line one character
  175. 'at a time.
  176. For I = 1 To CmdLnLen
  177. C = Mid(CmdLine, I, 1)
  178. 'Test for space or tab.
  179. If (C <> " " And C <> vbTab) Then
  180. 'Neither space nor tab.
  181. 'Test if already in argument.
  182. If Not InArg Then
  183. 'New argument begins.
  184. 'Test for too many arguments.
  185. If NumArgs = MaxArgs Then Exit For
  186. NumArgs = NumArgs + 1
  187. InArg = True
  188. End If
  189. 'Concatenate character to current argument.
  190. ArgArray(NumArgs) = ArgArray(NumArgs) & C
  191. Else
  192. 'Found a space or tab.
  193. 'Set InArg flag to False.
  194. InArg = False
  195. End If
  196. Next I
  197. 'Resize array just enough to hold arguments.
  198. ReDim Preserve ArgArray(NumArgs)
  199. 'Return Array in Function name.
  200. GetCommandLine = ArgArray()
  201. End Function