Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Performance Question

Performance Question

Scheduled Pinned Locked Moved Visual Basic
data-structuresperformancetutorialquestioncode-review
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    programmervb netc
    wrote on last edited by
    #1

    Can someone please look at this and make some suggestions on how to improve the performance of this snippet this is killing one of our apps. Private Function fbParseParameters(ByVal sArgs() As String) As Boolean Dim tTemp As String ' fbParseParameters = True Dim iII As Integer = 0 If sArgs.Length > 0 Then ' each parameter is broken into a seperate array item. While iII < sArgs.Length tTemp = sArgs(iII).ToUpper ' look at the parms, and figure out which is which... If tTemp.IndexOf("DATABASEHOST=") > 0 Then myConnectionInfo.tDatabaseHost = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("USERNAME=") > 0 Then myConnectionInfo.tUserName = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("USERNUMBER=") > 0 Then myConnectionInfo.lUserNumber = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("PASSWORD=") > 0 Then myConnectionInfo.tPassword = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("LOCALE=") > 0 Then myConnectionInfo.tCurrentLocaleCode = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("LOCALEDESCR=") > 0 Then myConnectionInfo.tCurrentLocale = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("MODULE=") > 0 Then strApplicationInfo.tCurrentModule = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("REPORT=") > 0 Then strApplicationInfo.tReport = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If

    K D 2 Replies Last reply
    0
    • P programmervb netc

      Can someone please look at this and make some suggestions on how to improve the performance of this snippet this is killing one of our apps. Private Function fbParseParameters(ByVal sArgs() As String) As Boolean Dim tTemp As String ' fbParseParameters = True Dim iII As Integer = 0 If sArgs.Length > 0 Then ' each parameter is broken into a seperate array item. While iII < sArgs.Length tTemp = sArgs(iII).ToUpper ' look at the parms, and figure out which is which... If tTemp.IndexOf("DATABASEHOST=") > 0 Then myConnectionInfo.tDatabaseHost = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("USERNAME=") > 0 Then myConnectionInfo.tUserName = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("USERNUMBER=") > 0 Then myConnectionInfo.lUserNumber = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("PASSWORD=") > 0 Then myConnectionInfo.tPassword = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("LOCALE=") > 0 Then myConnectionInfo.tCurrentLocaleCode = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("LOCALEDESCR=") > 0 Then myConnectionInfo.tCurrentLocale = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("MODULE=") > 0 Then strApplicationInfo.tCurrentModule = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("REPORT=") > 0 Then strApplicationInfo.tReport = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If

      K Offline
      K Offline
      kaddim
      wrote on last edited by
      #2

      You're using tTemp.Substring(tTemp.IndexOf("=") + 1 multiple times in each block. If you defined your search strings as constants, you could skip this. For example: private const DATABASEHOST_ARG As String = "DATABASEHOST=" ... If tTemp.IndexOf(DATABASEHOST_ARG) > 0 Then myConnectionInfo.tDatabaseHost = tTemp.Substring(DATABASEHOST_ARG.Length(), _ (tTemp.Length - DATABASEHOST_ARG.Length()) End If I didn't compile, so formatting may be off - and make sure you check to see that I've got the Substring starting index correct. I'm pretty sure that the '+ 1' is no longer necessary. Simply rinse and repeat for your other blocks and your helpful compiler should replace a lot of "IndexOf" operations with simple math!

      P 1 Reply Last reply
      0
      • K kaddim

        You're using tTemp.Substring(tTemp.IndexOf("=") + 1 multiple times in each block. If you defined your search strings as constants, you could skip this. For example: private const DATABASEHOST_ARG As String = "DATABASEHOST=" ... If tTemp.IndexOf(DATABASEHOST_ARG) > 0 Then myConnectionInfo.tDatabaseHost = tTemp.Substring(DATABASEHOST_ARG.Length(), _ (tTemp.Length - DATABASEHOST_ARG.Length()) End If I didn't compile, so formatting may be off - and make sure you check to see that I've got the Substring starting index correct. I'm pretty sure that the '+ 1' is no longer necessary. Simply rinse and repeat for your other blocks and your helpful compiler should replace a lot of "IndexOf" operations with simple math!

        P Offline
        P Offline
        programmervb netc
        wrote on last edited by
        #3

        Thank you I will add that with some other things that I have done to it and that should help.

        Humble Programmer

        1 Reply Last reply
        0
        • P programmervb netc

          Can someone please look at this and make some suggestions on how to improve the performance of this snippet this is killing one of our apps. Private Function fbParseParameters(ByVal sArgs() As String) As Boolean Dim tTemp As String ' fbParseParameters = True Dim iII As Integer = 0 If sArgs.Length > 0 Then ' each parameter is broken into a seperate array item. While iII < sArgs.Length tTemp = sArgs(iII).ToUpper ' look at the parms, and figure out which is which... If tTemp.IndexOf("DATABASEHOST=") > 0 Then myConnectionInfo.tDatabaseHost = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("USERNAME=") > 0 Then myConnectionInfo.tUserName = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("USERNUMBER=") > 0 Then myConnectionInfo.lUserNumber = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("PASSWORD=") > 0 Then myConnectionInfo.tPassword = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("LOCALE=") > 0 Then myConnectionInfo.tCurrentLocaleCode = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("LOCALEDESCR=") > 0 Then myConnectionInfo.tCurrentLocale = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("MODULE=") > 0 Then strApplicationInfo.tCurrentModule = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If If tTemp.IndexOf("REPORT=") > 0 Then strApplicationInfo.tReport = tTemp.Substring(tTemp.IndexOf("=") + 1, _ (tTemp.Length - (tTemp.IndexOf("=") + 1))) End If

          D Offline
          D Offline
          darkelv
          wrote on last edited by
          #4

          Split the string with delimiter "/" into string array, then from there split with delimiter "=" then put the pair into HashTable. Then assign your class from the HashTable (check for empty), ie strSystemInfo.lTherapistNum = hashTable["THERAPISTNUM"].Value;

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups