Results 1 to 12 of 12

Thread: does my computer suck?

  1. #1

    Thread Starter
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340

    does my computer suck?

    i made a program, see thread "This code is pissing me off" that times how long it takes a computer to count to 1 billion. I ran it several times under different conditions, and the average was about 18 seconds. This seems very long for me, it seems that it should only take a few seconds. Any ideas?

    my computer is a 450mhz PIII.

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I had to remove the optimations for msvc to get that i wanted to actually loop

    Code:
    ; 234  : 	for(int c=0;c<1000000000;++c);
    
    	mov	DWORD PTR _c$[ebp], 0
    	jmp	SHORT $L8938
    $L8939:
    	mov	eax, DWORD PTR _c$[ebp]
    	add	eax, 1
    	mov	DWORD PTR _c$[ebp], eax
    $L8938:
    	cmp	DWORD PTR _c$[ebp], 1000000000		; 3b9aca00H
    	jge	SHORT $L8940
    	jmp	SHORT $L8939
    Anyways it seems to take 6 instructions per loop i have a 1.33Ghz Thunderbird (running at 1.00Ghz currently) and it takes about 6 seconds. That makes sense: 1Billion*6~6G Cpu cycles.
    This loop seems to be incredibly stupid anyway, I would use a register, and cut down the amount of instructions to 3. Probably something to do with the optimations.

    Post your assembler listings and we'll see what's taking so long. I guess you have 8 cpu cycles (0.45*18=8)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772

    Re: does my computer suck?

    Originally posted by sail3005
    does my computer suck?
    Yes
    Alcohol & calculus don't mix.
    Never drink & derive.

  4. #4
    Zaei
    Guest
    A billion is a pretty big number (ever counted to a thousand?). You might try making the loop counter "register" to force it into a register.

    Z.

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Originally posted by Zaei
    A billion is a pretty big number (ever counted to a thousand?). You might try making the loop counter "register" to force it into a register.

    Z.
    MSVC ignores that pretty much (ask parksie )
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    jim mcnamara
    Guest
    Now that sucks, to borrow parlance. This is a 'feature' that makes me mad.

    Register absolutely does not work for MSVC++. The docset says it is completely ignored. Like we can't figure out how to optimize code. If something becomes 'register' it has nothing to do with whether you declare it that way or not. The compiler is smrter than us, just ask Kedaman


  7. #7
    Zaei
    Guest
    Indeed that does suck. Well, that is why we have inline assembly.

    From: MSDN
    The 32-bit compiler does not honor user requests for register variables.
    Samurai Zaei says: "What? You dare to not honor my request!? Prepare for death!"

    Z.

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Originally posted by Zaei
    Indeed that does suck. Well, that is why we have inline assembly.



    Samurai Zaei says: "What? You dare to not honor my request!? Prepare for death!"

    Z.
    Problem is inline assembly and optimation does not work together, once you put something in asm everything the optimizer works so hard for to inline will be wasted. So inline asm is only good when you have something specific, so it's very uncomfortable to have around in the lower layers.

    The compiler usually thinks it's smarter, but when you've finally finished your expression templates you'll notice what kinda dumbass it really is.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    For a quick by-hand optimization:
    Code:
    	mov	eax, 0
    $L8939:
    	inc	eax
    	cmp	eax, 1000000000		; 3b9aca00H
    	jl	SHORT $L8939
    You can make this faster with the LOOP instruction, but I don't know how to use it. The worst thing here is the jmp instruction, it flushes the prefetch queue (meaning the next instruction takes 5-7 cycles instead of 1).
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    mov ecx, 1000000000
    f:
    loop f
    That should do it
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  11. #11

    Thread Starter
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    Originally posted by kedaman

    Post your assembler listings and we'll see what's taking so long. I guess you have 8 cpu cycles (0.45*18=8)
    How do i get the ASM code? I wrote it in C++.

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  12. #12
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You can select it to list asm code into a file in project>settings>C++>Category>listing files
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width