Performance Considerations....

Author Message
Cobalt

  • Total Posts : 17
  • Scores: 0
  • Reward points : 0
  • Joined: 2/3/2005
  • Location:
  • Status: offline
Performance Considerations.... Saturday, March 05, 2005 4:25 PM (permalink)
0
I know that I feel the correct answer to this question is, but I'm looking for other opinions (and I know I came to the right spot for that. )

When parsing a log file I have to examine the contents of each line and make a decision based on what I find. Two sample lines from the file are below. If you recognize what they are from, you get an extra 10 points.

(2005-02-27 07:21:38 Periodic-Log All 00.000% 00.000% 0 0 0 0)
(2005-02-27 07:28:36 207.200.81.151 - W3SVC2 Server001 10.10.10.10 80 HEAD /Default.aspx - 200 0 389 176 32 HTTP/1.1 www.pcsupport.net Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) - -)

The first line is just one of about five differently formatted lines that I'm not interested in. The data I'm interested in is contained in the second line.

The question is when checking the line for interest, is it better to:

1. Use the InStr function to look for what interests me
- or -
2. Use the Mid function to check for a specific character value.

For the sake of this discussion, we are going to assume that the value on which I will decide if I'm interested in or not is always in the same column.

To summarise:

From a performance standpoint is it better to use the Mid or InStr function?
J. Michael Lynch
Senior Guru - pcSupport Networks
www.pcsupport.net
 
#1
    token

    • Total Posts : 1917
    • Scores: 0
    • Reward points : 0
    • Joined: 1/14/2005
    • Location:
    • Status: offline
    Re: Performance Considerations.... Saturday, March 05, 2005 5:10 PM (permalink)
    0
    I would use regular expression to match for the pattern you desire in the IIS log files.

    What did I win for my 10 points ? :D

     
    #2
      Cobalt

      • Total Posts : 17
      • Scores: 0
      • Reward points : 0
      • Joined: 2/3/2005
      • Location:
      • Status: offline
      Re: Performance Considerations.... Monday, March 07, 2005 1:29 PM (permalink)
      0
      But from a performance point of view, which is the least expensive?

      1. InStr
      2. Mid
      3. RegEx?

      Especially considering that the IIS Log files can run into the "OHMYGODIT'SFREAKINHUGE" category.

      Your 10 points can be traded in on a warm fuzzy feeling knowing that you were the only one who responded correctly (or at all).
       
      #3
        tnoonan

        • Total Posts : 364
        • Scores: 0
        • Reward points : 0
        • Joined: 12/14/2004
        • Location:
        • Status: offline
        Re: Performance Considerations.... Monday, March 07, 2005 1:46 PM (permalink)
        0
        Why don't you write the script with option to pick which one you want and benchmark it?
         
        #4
          token

          • Total Posts : 1917
          • Scores: 0
          • Reward points : 0
          • Joined: 1/14/2005
          • Location:
          • Status: offline
          Re: Performance Considerations.... Monday, March 07, 2005 2:54 PM (permalink)
          0
          I do not believe there are significant differences though. I;ve done some similiar benchmarking on other types of functions and objects and found the difference to be negligible.

           
          #5
            tnoonan

            • Total Posts : 364
            • Scores: 0
            • Reward points : 0
            • Joined: 12/14/2004
            • Location:
            • Status: offline
            Re: Performance Considerations.... Monday, March 07, 2005 2:59 PM (permalink)
            0
            I wonder what folder this would be MSFTPSVC1. Just because no one else post does not make them ignorant
             
            #6
              token

              • Total Posts : 1917
              • Scores: 0
              • Reward points : 0
              • Joined: 1/14/2005
              • Location:
              • Status: offline
              Re: Performance Considerations.... Monday, March 07, 2005 3:27 PM (permalink)
              0
              If you are REALLY interested, here are some stats.

              One text file containting 66840 lines. The first 2 methods (re and instr , respectively) matches the string "mozilla", the third method matches the string "mizilla" at position column 137.

              First stat has a loop of 1 time.
              re : Matches: 1361 Time took: 1.242188 sec Lines: 66840 Lines/Sec: 53808
              instr: Matches: 213 Time took: 0.8828125 sec Lines: 66840 Lines/Sec: 75713
              mid : Matches: 2 Time took: 0.7890625 sec Lines: 66840 Lines/Sec: 84708

              Second stat has a loop of 10 times.
              re : Matches: 13610 Time took: 13.64063 sec Lines: 668400 Lines/Sec: 49000
              instr: Matches: 2130 Time took: 9.554688 sec Lines: 668400 Lines/Sec: 69955
              mid : Matches: 20 Time took: 9.203125 sec Lines: 668400 Lines/Sec: 72627

              First stat has a loop of 100 times.
              re : Matches: 136100 Time took: 135.5859 sec Lines: 6684000 Lines/Sec: 49297
              instr: Matches: 21300 Time took: 94.00781 sec Lines: 6684000 Lines/Sec: 71100
              mid : Matches: 200 Time took: 91.61719 sec Lines: 6684000 Lines/Sec: 72956
               
              #7
                tnoonan

                • Total Posts : 364
                • Scores: 0
                • Reward points : 0
                • Joined: 12/14/2004
                • Location:
                • Status: offline
                Re: Performance Considerations.... Monday, March 07, 2005 3:29 PM (permalink)
                0
                Too funny. That's Token Cant pass up a challenge
                 
                #8
                  token

                  • Total Posts : 1917
                  • Scores: 0
                  • Reward points : 0
                  • Joined: 1/14/2005
                  • Location:
                  • Status: offline
                  Re: Performance Considerations.... Monday, March 07, 2005 3:32 PM (permalink)
                  0
                   
                  #9
                    tnoonan

                    • Total Posts : 364
                    • Scores: 0
                    • Reward points : 0
                    • Joined: 12/14/2004
                    • Location:
                    • Status: offline
                    Re: Performance Considerations.... Monday, March 07, 2005 3:33 PM (permalink)
                    0
                    You the man token toke another>
                     
                    #10
                      tnoonan

                      • Total Posts : 364
                      • Scores: 0
                      • Reward points : 0
                      • Joined: 12/14/2004
                      • Location:
                      • Status: offline
                      Re: Performance Considerations.... Monday, March 07, 2005 3:47 PM (permalink)
                      0
                      Hey your not the only one who get some inspiration dude.
                       
                      #11
                        tnoonan

                        • Total Posts : 364
                        • Scores: 0
                        • Reward points : 0
                        • Joined: 12/14/2004
                        • Location:
                        • Status: offline
                        Re: Performance Considerations.... Monday, March 07, 2005 3:49 PM (permalink)
                        0
                        Roll with it.
                         
                        #12
                          token

                          • Total Posts : 1917
                          • Scores: 0
                          • Reward points : 0
                          • Joined: 1/14/2005
                          • Location:
                          • Status: offline
                          Re: Performance Considerations.... Monday, March 07, 2005 5:51 PM (permalink)
                          0
                          tnoonan, Who are you talking to, me ?

                           
                          #13

                            Online Bookmarks Sharing: Share/Bookmark

                            Jump to:

                            Current active users

                            There are 0 members and 1 guests.

                            Icon Legend and Permission

                            • New Messages
                            • No New Messages
                            • Hot Topic w/ New Messages
                            • Hot Topic w/o New Messages
                            • Locked w/ New Messages
                            • Locked w/o New Messages
                            • Read Message
                            • Post New Thread
                            • Reply to message
                            • Post New Poll
                            • Submit Vote
                            • Post reward post
                            • Delete my own posts
                            • Delete my own threads
                            • Rate post

                            2000-2012 ASPPlayground.NET Forum Version 3.9