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. Other Discussions
  3. The Weird and The Wonderful
  4. Why is my code so slow??

Why is my code so slow??

Scheduled Pinned Locked Moved The Weird and The Wonderful
testingbeta-testingquestion
18 Posts 11 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.
  • V vonb

    Strange behavior in my code, every operation it had to do took 5 seconds.. At the end I found it:

    System.Threading.Thread.Sleep(5000);

    It was sitting there since the beggining of the project. Commented it, testing, and it worked normally. Can't remember why I made the system sleep 5 secs, on 10 operations it's ok, but on production we got 2'500 operations, took forever.. :zzz:

    The signature is in building process.. Please wait...

    J Offline
    J Offline
    Jorgen Andersson
    wrote on last edited by
    #2

    Don't you just love comments.

    Be excellent to each other. And... PARTY ON, DUDES! Abraham Lincoln

    V R 2 Replies Last reply
    0
    • J Jorgen Andersson

      Don't you just love comments.

      Be excellent to each other. And... PARTY ON, DUDES! Abraham Lincoln

      V Offline
      V Offline
      vonb
      wrote on last edited by
      #3

      I actually hate them.. But they are usefull, I agree..

      The signature is in building process.. Please wait...

      J 1 Reply Last reply
      0
      • V vonb

        Strange behavior in my code, every operation it had to do took 5 seconds.. At the end I found it:

        System.Threading.Thread.Sleep(5000);

        It was sitting there since the beggining of the project. Commented it, testing, and it worked normally. Can't remember why I made the system sleep 5 secs, on 10 operations it's ok, but on production we got 2'500 operations, took forever.. :zzz:

        The signature is in building process.. Please wait...

        B Offline
        B Offline
        BillW33
        wrote on last edited by
        #4

        Yeah, that would slow things down. Using a to do list would help to remember to clean up such things. It is like a comment, but looks like //TODO: Remove this after testing. Then you can see the to so list in Visual Studio :)

        Just because the code works, it doesn't mean that it is good code.

        OriginalGriffO A 2 Replies Last reply
        0
        • J Jorgen Andersson

          Don't you just love comments.

          Be excellent to each other. And... PARTY ON, DUDES! Abraham Lincoln

          R Offline
          R Offline
          Rage
          wrote on last edited by
          #5

          Those that explain the bad code, or those to comment out the bad code ?

          ~RaGE();

          I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus Do not feed the troll ! - Common proverb

          J L 2 Replies Last reply
          0
          • V vonb

            I actually hate them.. But they are usefull, I agree..

            The signature is in building process.. Please wait...

            J Offline
            J Offline
            Jorgen Andersson
            wrote on last edited by
            #6

            I love them when other do them.

            Be excellent to each other. And... PARTY ON, DUDES! Abraham Lincoln

            1 Reply Last reply
            0
            • R Rage

              Those that explain the bad code, or those to comment out the bad code ?

              ~RaGE();

              I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus Do not feed the troll ! - Common proverb

              J Offline
              J Offline
              Jorgen Andersson
              wrote on last edited by
              #7

              Well, both are better then not. :doh:

              Be excellent to each other. And... PARTY ON, DUDES! Abraham Lincoln

              1 Reply Last reply
              0
              • R Rage

                Those that explain the bad code, or those to comment out the bad code ?

                ~RaGE();

                I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus Do not feed the troll ! - Common proverb

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #8

                www.DoInternship.com

                1 Reply Last reply
                0
                • B BillW33

                  Yeah, that would slow things down. Using a to do list would help to remember to clean up such things. It is like a comment, but looks like //TODO: Remove this after testing. Then you can see the to so list in Visual Studio :)

                  Just because the code works, it doesn't mean that it is good code.

                  OriginalGriffO Offline
                  OriginalGriffO Offline
                  OriginalGriff
                  wrote on last edited by
                  #9

                  Yep - I do it all the time - so they show up in the VS "Task List". :thumbsup:

                  The only instant messaging I do involves my middle finger.

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                  1 Reply Last reply
                  0
                  • V vonb

                    Strange behavior in my code, every operation it had to do took 5 seconds.. At the end I found it:

                    System.Threading.Thread.Sleep(5000);

                    It was sitting there since the beggining of the project. Commented it, testing, and it worked normally. Can't remember why I made the system sleep 5 secs, on 10 operations it's ok, but on production we got 2'500 operations, took forever.. :zzz:

                    The signature is in building process.. Please wait...

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #10

                    You should have decreased the value.

                    V B 2 Replies Last reply
                    0
                    • P PIEBALDconsult

                      You should have decreased the value.

                      V Offline
                      V Offline
                      vonb
                      wrote on last edited by
                      #11

                      To 4'999??? or to 1?? :)

                      The signature is in building process.. Please wait...

                      P S 2 Replies Last reply
                      0
                      • V vonb

                        To 4'999??? or to 1?? :)

                        The signature is in building process.. Please wait...

                        P Offline
                        P Offline
                        PIEBALDconsult
                        wrote on last edited by
                        #12

                        Maybe by twenty-five to fifty percent; you need to leave some.

                        V 1 Reply Last reply
                        0
                        • P PIEBALDconsult

                          Maybe by twenty-five to fifty percent; you need to leave some.

                          V Offline
                          V Offline
                          vonb
                          wrote on last edited by
                          #13

                          In this case I don't need it at all.. It was there for debugging, because without the sleep, debugging just went too fast.

                          The signature is in building process.. Please wait...

                          N 1 Reply Last reply
                          0
                          • V vonb

                            In this case I don't need it at all.. It was there for debugging, because without the sleep, debugging just went too fast.

                            The signature is in building process.. Please wait...

                            N Offline
                            N Offline
                            Nagy Vilmos
                            wrote on last edited by
                            #14

                            No you need to leave some delay in for a development holiday. When Boss Man says the app is too slow, tell him you'll have a look, spend two days faffing, reduce the wait by 20% and tell him you've optimised the code. Simples.

                            speramus in juniperus

                            A 1 Reply Last reply
                            0
                            • B BillW33

                              Yeah, that would slow things down. Using a to do list would help to remember to clean up such things. It is like a comment, but looks like //TODO: Remove this after testing. Then you can see the to so list in Visual Studio :)

                              Just because the code works, it doesn't mean that it is good code.

                              A Offline
                              A Offline
                              AmitGajjar
                              wrote on last edited by
                              #15

                              :thumbsup:

                              Thanks -Amit Gajjar

                              1 Reply Last reply
                              0
                              • N Nagy Vilmos

                                No you need to leave some delay in for a development holiday. When Boss Man says the app is too slow, tell him you'll have a look, spend two days faffing, reduce the wait by 20% and tell him you've optimised the code. Simples.

                                speramus in juniperus

                                A Offline
                                A Offline
                                AmitGajjar
                                wrote on last edited by
                                #16

                                I guess you are doing the same :laugh:

                                Thanks -Amit Gajjar

                                1 Reply Last reply
                                0
                                • P PIEBALDconsult

                                  You should have decreased the value.

                                  B Offline
                                  B Offline
                                  Bernhard Hiller
                                  wrote on last edited by
                                  #17

                                  Exactly. You understand the meaning of this valuable coding practise described in

                                  "Real World Software Development - Volume I: Coding Patterns" by W., T., and F.

                                  1 Reply Last reply
                                  0
                                  • V vonb

                                    To 4'999??? or to 1?? :)

                                    The signature is in building process.. Please wait...

                                    S Offline
                                    S Offline
                                    SortaCore
                                    wrote on last edited by
                                    #18

                                    vonb wrote:

                                    To 4'999??? or to 1?? :)

                                    Silly, to -1. (Incidentally, sleeping for 0 cycles has "special behaviour")

                                    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