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. The Lounge
  3. how long does it take

how long does it take

Scheduled Pinned Locked Moved The Lounge
question
33 Posts 17 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.
  • G Gary R Wheeler

    Somewhere between 4.5 and 7.2 femtoparsecs.

    Software Zen: delete this;
    Fold With Us![^]

    Y Offline
    Y Offline
    yassir hannoun
    wrote on last edited by
    #5

    i mean counting 0 1 2 3 4 5 6 7 .... 2147483647 by the way i m runin it now and i will get the result soon here is what i m doing DateTime start = DateTime.Now; for (int i = 0; i < int.MaxValue; i++) { Console.WriteLine(i); } DateTime finish = DateTime.Now; Console.WriteLine("counting started at {0} and finished at {1}", start, finish);

    A 1 Reply Last reply
    0
    • Y yassir hannoun

      how long does it take for a computer to count from 0 to the maximum value of int ??

      A Offline
      A Offline
      Anton Afanasyev
      wrote on last edited by
      #6

      0 milliseconds - the VC++ compiler optimized the useless loop out of the program.

      1 Reply Last reply
      0
      • Y yassir hannoun

        i mean counting 0 1 2 3 4 5 6 7 .... 2147483647 by the way i m runin it now and i will get the result soon here is what i m doing DateTime start = DateTime.Now; for (int i = 0; i < int.MaxValue; i++) { Console.WriteLine(i); } DateTime finish = DateTime.Now; Console.WriteLine("counting started at {0} and finished at {1}", start, finish);

        A Offline
        A Offline
        Anton Afanasyev
        wrote on last edited by
        #7

        You have to realize you are slowing it down by A LOT by calling Console.WriteLine(i); In fact, calling ANYTHING inside that loop will slow it down. remove that line, and run again. also, make sure you run it without optimizations turned on, or the optimizer would just strip the forloop out.

        G J 2 Replies Last reply
        0
        • A Anton Afanasyev

          You have to realize you are slowing it down by A LOT by calling Console.WriteLine(i); In fact, calling ANYTHING inside that loop will slow it down. remove that line, and run again. also, make sure you run it without optimizations turned on, or the optimizer would just strip the forloop out.

          G Offline
          G Offline
          Gary Kirkham
          wrote on last edited by
          #8

          But unless the loop writes something then how do you know the computer is counting...it could be skipping the loop altogether and laughing at you behind your back.

          Gary Kirkham Forever Forgiven and Alive in the Spirit The fool has said in his heart, "There is no God" Me blog, You read

          Y O M 3 Replies Last reply
          0
          • G Gary Kirkham

            But unless the loop writes something then how do you know the computer is counting...it could be skipping the loop altogether and laughing at you behind your back.

            Gary Kirkham Forever Forgiven and Alive in the Spirit The fool has said in his heart, "There is no God" Me blog, You read

            Y Offline
            Y Offline
            yassir hannoun
            wrote on last edited by
            #9

            Gary Kirkham wrote:

            it could be skipping the loop altogether and laughing at you behind your back.

            hehehehe anyway it is runing for more than 1 hour so far what i got is 154500000

            P 1 Reply Last reply
            0
            • G Gary Kirkham

              But unless the loop writes something then how do you know the computer is counting...it could be skipping the loop altogether and laughing at you behind your back.

              Gary Kirkham Forever Forgiven and Alive in the Spirit The fool has said in his heart, "There is no God" Me blog, You read

              O Offline
              O Offline
              Oakman
              wrote on last edited by
              #10

              Gary Kirkham wrote:

              laughing at you behind your back.

              Mine does that a lot!

              Jon Smith & Wesson: The original point and click interface

              G 1 Reply Last reply
              0
              • Y yassir hannoun

                how long does it take for a computer to count from 0 to the maximum value of int ??

                M Offline
                M Offline
                Marc Clifton
                wrote on last edited by
                #11

                If a program encounters a loop in a forest, does the computer actually execute it? Marc

                Thyme In The Country Interacx My Blog

                1 Reply Last reply
                0
                • Y yassir hannoun

                  how long does it take for a computer to count from 0 to the maximum value of int ??

                  P Offline
                  P Offline
                  Pete OHanlon
                  wrote on last edited by
                  #12

                  Release, Debug or Plain English?

                  Deja View - the feeling that you've seen this post before.

                  My blog | My articles

                  M 1 Reply Last reply
                  0
                  • Y yassir hannoun

                    Gary Kirkham wrote:

                    it could be skipping the loop altogether and laughing at you behind your back.

                    hehehehe anyway it is runing for more than 1 hour so far what i got is 154500000

                    P Offline
                    P Offline
                    Pete OHanlon
                    wrote on last edited by
                    #13

                    OK - I just ran it and it took 8 seconds.

                    static void Main(string[] args)
                    {
                    Console.WriteLine(DateTime.Now.ToString());
                    for (int i = 0; i < int.MaxValue; i++)
                    {
                    if (i == int.MaxValue - 2)
                    {
                    Console.WriteLine("Hi");
                    }
                    }
                    Console.WriteLine(DateTime.Now.ToString());
                    Console.ReadLine();
                    }

                    Two things come to mind - why do you want to do this and do you realise you just asked a programming question in the lounge?

                    Deja View - the feeling that you've seen this post before.

                    My blog | My articles

                    Y L 2 Replies Last reply
                    0
                    • O Oakman

                      Gary Kirkham wrote:

                      laughing at you behind your back.

                      Mine does that a lot!

                      Jon Smith & Wesson: The original point and click interface

                      G Offline
                      G Offline
                      Gary Kirkham
                      wrote on last edited by
                      #14

                      I would settle for that...mine openly mocks me.

                      Gary Kirkham Forever Forgiven and Alive in the Spirit The fool has said in his heart, "There is no God" Me blog, You read

                      1 Reply Last reply
                      0
                      • Y yassir hannoun

                        how long does it take for a computer to count from 0 to the maximum value of int ??

                        realJSOPR Offline
                        realJSOPR Offline
                        realJSOP
                        wrote on last edited by
                        #15

                        You can't do that on Vista unless you have SP1 because Vista never finishes calculating how long it's going to take.

                        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                        -----
                        "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                        P 1 Reply Last reply
                        0
                        • realJSOPR realJSOP

                          You can't do that on Vista unless you have SP1 because Vista never finishes calculating how long it's going to take.

                          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                          -----
                          "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                          P Offline
                          P Offline
                          Pete OHanlon
                          wrote on last edited by
                          #16

                          On Vista, the answer is "2 seconds remaining." and remains that way till the Sun shrinks to the size of a lump of coal.

                          Deja View - the feeling that you've seen this post before.

                          My blog | My articles

                          M 1 Reply Last reply
                          0
                          • P Pete OHanlon

                            Release, Debug or Plain English?

                            Deja View - the feeling that you've seen this post before.

                            My blog | My articles

                            M Offline
                            M Offline
                            martin_hughes
                            wrote on last edited by
                            #17

                            Pete O'Hanlon wrote:

                            Plain English

                            Shhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!

                            P 1 Reply Last reply
                            0
                            • G Gary Kirkham

                              But unless the loop writes something then how do you know the computer is counting...it could be skipping the loop altogether and laughing at you behind your back.

                              Gary Kirkham Forever Forgiven and Alive in the Spirit The fool has said in his heart, "There is no God" Me blog, You read

                              M Offline
                              M Offline
                              martin_hughes
                              wrote on last edited by
                              #18

                              :laugh: Mine does this all the time - lousy computer!

                              1 Reply Last reply
                              0
                              • M martin_hughes

                                Pete O'Hanlon wrote:

                                Plain English

                                Shhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!

                                P Offline
                                P Offline
                                Pete OHanlon
                                wrote on last edited by
                                #19

                                It's like Candyman. If you say Plain English 3 times, up pops Osmo.

                                Deja View - the feeling that you've seen this post before.

                                My blog | My articles

                                M 1 Reply Last reply
                                0
                                • P Pete OHanlon

                                  On Vista, the answer is "2 seconds remaining." and remains that way till the Sun shrinks to the size of a lump of coal.

                                  Deja View - the feeling that you've seen this post before.

                                  My blog | My articles

                                  M Offline
                                  M Offline
                                  martin_hughes
                                  wrote on last edited by
                                  #20

                                  Nonsense - Vista recognises such an operation as a security risk, prompts the user for administrative access and then refuses to run the task regardless :)

                                  Y 1 Reply Last reply
                                  0
                                  • P Pete OHanlon

                                    OK - I just ran it and it took 8 seconds.

                                    static void Main(string[] args)
                                    {
                                    Console.WriteLine(DateTime.Now.ToString());
                                    for (int i = 0; i < int.MaxValue; i++)
                                    {
                                    if (i == int.MaxValue - 2)
                                    {
                                    Console.WriteLine("Hi");
                                    }
                                    }
                                    Console.WriteLine(DateTime.Now.ToString());
                                    Console.ReadLine();
                                    }

                                    Two things come to mind - why do you want to do this and do you realise you just asked a programming question in the lounge?

                                    Deja View - the feeling that you've seen this post before.

                                    My blog | My articles

                                    Y Offline
                                    Y Offline
                                    yassir hannoun
                                    wrote on last edited by
                                    #21

                                    i m doing it just fo fun :d

                                    1 Reply Last reply
                                    0
                                    • M martin_hughes

                                      Nonsense - Vista recognises such an operation as a security risk, prompts the user for administrative access and then refuses to run the task regardless :)

                                      Y Offline
                                      Y Offline
                                      yassir hannoun
                                      wrote on last edited by
                                      #22

                                      doing it under XP Pro SP2

                                      M 1 Reply Last reply
                                      0
                                      • P Pete OHanlon

                                        It's like Candyman. If you say Plain English 3 times, up pops Osmo.

                                        Deja View - the feeling that you've seen this post before.

                                        My blog | My articles

                                        M Offline
                                        M Offline
                                        martin_hughes
                                        wrote on last edited by
                                        #23

                                        Hmmm. I always thought of him as more as a noxious cloud of bum gas: invisible, lingering and stinking up the joint a treat. :)

                                        1 Reply Last reply
                                        0
                                        • Y yassir hannoun

                                          how long does it take for a computer to count from 0 to the maximum value of int ??

                                          M Offline
                                          M Offline
                                          Mladen Jankovic
                                          wrote on last edited by
                                          #24

                                          What computer? What language? What compiler? What version of compiler... I guess you’re not interested in result of 16-bit DOS program compiled by compiler with sizeof(int) = 4 that runs in 32-bit protected mode extender inside virtual 16-bit DOS box on 32-bit Windows 98 running on virtual machine run by 32-bit VirtualPC on 64-bit Vista through WoW64? Or maybe you are? :~

                                          Mostly, when you see programmers, they aren't doing anything. One of the attractive things about programmers is that you cannot tell whether or not they are working simply by looking at them. Very often they're sitting there seemingly drinking coffee and gossiping, or just staring into space. What the programmer is trying to do is get a handle on all the individual and unrelated ideas that are scampering around in his head. (Charles M Strauss)

                                          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