Results 1 to 22 of 22

Thread: C++ vs VB and C#

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    81

    Exclamation C++ vs VB and C#

    ive made a test of speed between VB and VC++:
    VB Code:
    1. for i=0 to 786432 ' (1024x768)
    2.      buffer(i)=Color
    3. next i
    runs at 15.81 FPS
    empty loop runs at 23.5 FPS
    on VC++ the same code runs at 232.3 FPS
    and 320.3 FPS for the empty for.
    can someone post here the results of C# on this test?
    use QueryPerformanceFrequency() and QueryPerformanceCounter() to count the FPS.
    the testing executable should be executed from outside the IDE (it might slow it down and change the real result)

  2. #2
    Hyperactive Member
    Join Date
    Jun 2002
    Posts
    299
    with virtual pascal:
    runs 20 fps.
    empty loop 100 fps.

    Better than VB, but just only.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    81
    thanks for adding your language to the comparison, i should have said it before, every language is welcome.
    please post here more tests
    (by the way, i know of pascal and delphi, whats virtual pascal?)

  4. #4
    Sascha
    Guest
    Comparing the speed of languages is only usefull when done on the same machine, so I don't think what you are trying to achieve here makes much sence,

    best regards

    Sascha

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    81
    you got a point there ;-)
    ive thought of it myself just before ive read youre post (when ive replied on the Game and Graphic forum)
    please program the exe on a certain lang and post the EXE here by the name of the language, i'll run it on my comp so we could compare it.

  6. #6
    Hyperactive Member
    Join Date
    Jun 2002
    Posts
    299
    Instructions are important, please read.

    Just run both of these, and it will output a number. divide it by 5. That's how many milliseconds iit takes, so for FPS, divide 1000 into it(example below). The faster one is obviously the empty one. PS: The only difference between virtual and normal, is, well, the people who named the compiler No difference


    FPS=1000/(MILLISECONDS/5)
    so an output of 50 would be 100 FPS!

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    81
    recoded my program:
    Code:
    //VARs
    const arrSize = 1024*768;
    DWORD bBuffer[arrSize];
    char str[20];
    _int64 iFreq,iStart,iEnd, sum;
    _int32 i,j;
    //program:
    
    			QueryPerformanceFrequency((LARGE_INTEGER *)&iFreq);
    			iFreq/=1000;
    			if (iFreq) {
    			QueryPerformanceCounter((LARGE_INTEGER *)&iStart);
    			iStart/=iFreq;
    			sum=0;
    			for(j=0;j<100;++j) {
    				for(i=0;i<arrSize;++i) {
    					bBuffer[i]=12421;
    				}	
    				QueryPerformanceCounter((LARGE_INTEGER *)&iEnd);
    				iEnd/=iFreq;
    				sum=iEnd-iStart;
    			}
    			MessageBox(NULL,_i64toa(100000/((sum)/(iFreq/1000)),str,10),"Title",MB_OK | MB_ICONINFORMATION);
    		}
    			else MessageBox(NULL,"Error!, no timer","Error!!!",MB_OK);
    the results on my comp were:
    356.09FPS avarage
    highest score is 380FPS
    lowest score is 321FPS

    using Delphi PsychoMark made an EXE which when i ran scored:
    250.58FPS avarage
    231FPS lowest
    270FPS highest

    please program in your favorite language and send me the EXE so i could write your score here.
    we'll soon have a compare table of the speeds of all languages used around this forum

    youre welcome to suggest any other tests and include some code and EXE so i'll compare them

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    81
    ok, my code wasnt counting FPS... i didnt think when i coded this... ;-)
    replcaed with:
    Code:
    				for(i=0;i<arrSize;++i) {
    					bBuffer[i]=12421;
    				}	
    				QueryPerformanceCounter((LARGE_INTEGER *)&iEnd);
    				iEnd/=iFreq;
    				sum=sum+(iEnd-iStart);
    			}
    			MessageBox(NULL,_i64toa(1000/sum,str,10),"Title",MB_OK | MB_ICONINFORMATION);
    now it makes more sence ;-)
    and Delphi is the winner!
    i got only 150FPS avarage....
    although my first code got better result - i mean the one without the new mistakes, ive screwed around with it and now i cant get my old code to work fast anymore

    compilers are wierd... i'll look into my assembly code later to see whats wrong if i'll have enough time (and when i'll be calm which wont likely will last enough time for me to realise whats wrong ;-))
    i know you cant judge just by that simple test, but if i'll see Delphi is faster, i'll RUN to it ;-)

  9. #9
    Hyperactive Member
    Join Date
    Jun 2002
    Posts
    299
    Instructions are important, please read.

    Just run both of these, and it will output a number. divide it by 5. That's how many milliseconds iit takes, so for FPS, divide 1000 into it(example below). The faster one is obviously the empty one. PS: The only difference between virtual and normal, is, well, the people who named the compiler No difference


    FPS=1000/(MILLISECONDS/5)
    so an output of 50 would be 100 FPS!

    Note: The loop with code in it got messed up in the compression or something, so I can only post the empty one.sorry
    Last edited by snakeeyes1000; Jul 5th, 2002 at 02:47 PM.

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    81
    i got only one number on the screen, it was 20...
    so if its not 2 and 0 (which will be too damn fast)
    its 250 FPS, thats close to what Delphi scored for the loop with the asignment. my VC++ was faster, but now im stuck with 160FPS...
    i have no idea whats wrong, its the same code....

  11. #11
    Jethro
    Guest
    And l bet if you knocked up some assembly code it would run the test even faster

  12. #12
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347
    short comment: the loops in vc++ and c# should be nearly equal

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    81
    please create an exe with it so i could test it on my comp then

  14. #14
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347

    Arrow

    ok - this sample is very basic

    1. see the code and try it
    2. run the same code in vc++
    3. see the results

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    81
    what exactly the massage: ### loops per sec says, is it how many times the loop for i=1 to 786432 ran with assigning a int32 array some value?
    if the loop does that, and you can run it the number of times per sec it says you can (which i seriously doubt)
    the C# is even faster the assembly ;-)
    it says it does 566116 loops per sec, whice is 200 times faster then any language....
    i think you got a major calc error there

  16. #16
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347
    I didn't say that this is for i = 1 to 786432

    this shows how many for loops the program is able to
    run through in 1 second

    for(int i = 0; i >= 0; i++)
    ...

    this means there is no end of the loop

    it only breaks after one second in my code and
    shows you the count of i

    there's no loop limitation of 786432

  17. #17
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347
    btw: this is only a loop check and has nothing to do with any screen resolution

  18. #18
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347

    Arrow

    ok - I just found an error in that app:

    I used the Application.DoEvents() method that is
    not usefull at this part of the code and dramatically
    slows the code.

    I removed the line and the loopcount should be much
    more higher than before.

    try it again.

  19. #19

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    81
    when i convert it to the for loop the other testing programs work with (the res 1024x768) so i could change it to FPS, C# is above VB with 35.551 FPS, but way below C and Delphi

  20. #20
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347
    35 FPS?

    I think that must be suboptimal code because even when you
    run several directx loops that contain of some rendering
    procedures, I get about 72 frames per second and this is in
    3D mode (1024 x 768)

    so i guess if you don't use that rendering thing, it must be possible to get much more frames.

  21. #21
    Hyperactive Member vbzero's Avatar
    Join Date
    Aug 2000
    Location
    Vienna
    Posts
    347
    i recommend to write the same code I gavve you in vc++
    and see how many loops it has done after 1 second.

    if it is much more, than vc++ would be more efficient...

    let's have a try

  22. #22

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    81
    i recommand that you create a program whice runs a loop of 1 to 786432 and modifies an array of int[786432] and calculate the FPS like all the other tests we did, i'll build a program that does what yours did too, so we can compare the two results
    (it might take me more then a day since i need to fix my computer)

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