Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Language Benchmarks

Options
24

Comments

  • Moderators, Science, Health & Environment Moderators Posts: 10,079 Mod ✭✭✭✭marco_polo


    Martyr wrote: »
    well marco most compilers would be smart enough to see this one, even i saw it before having to compile it ;)

    Must deserve some marks for effort. Good spot :), Thought I might get ya.


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Martyr wrote: »
    well marco most compilers would be smart enough to see this one, even i saw it before having to compile it ;)
    Really? which ones?


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    what about a mersenne twister or Lagged Fibonacci generator psuedo random number generator, or even some crypto?

    could you implement something like this?


  • Moderators, Science, Health & Environment Moderators Posts: 10,079 Mod ✭✭✭✭marco_polo


    Martyr wrote: »
    what about a mersenne twister or Lagged Fibonacci generator psuedo random number generator, or even some crypto?

    could you implement something like this?

    I could, but I have neither the time or the inclination TBH.


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    webmonkey wrote:
    Really? which ones?

    GNU C Compiler, MSVC, Pelles c compiler, watcom..most of them really.

    its not exactly something you could miss.(unless you're java programmer, who thinks it would be worth running a loop that does nothing)


  • Advertisement
  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    I could, but I have neither the time or the inclination TBH.

    yeah, i know and its because we already know that C/C++ is faster than Java.


  • Moderators, Science, Health & Environment Moderators Posts: 10,079 Mod ✭✭✭✭marco_polo


    Martyr wrote: »
    GNU C Compiler, MSVC, Pelles c compiler, watcom..most of them really.

    its not exactly something you could miss.(unless you're java programmer, who thinks it would be worth running a loop that does nothing)

    Ooh, bitchy.
    Martyr wrote: »
    yeah, i know and its because we already know that C/C++ is faster than Java.

    I am sure for the most part it still is marginally, what I don't understand is why you care so much.


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Martyr wrote: »
    GNU C Compiler, MSVC, Pelles c compiler, watcom..most of them really.

    its not exactly something you could miss.(unless you're java programmer, who thinks it would be worth running a loop that does nothing)
    Where did you learn this?


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    Ooh, bitchy.

    :D i'm only kiddin, marco take it easy.
    I am sure it still is for the most part, what I don't understand is why you care so much.

    because it would be interesting to see where it goes.

    this is a programming forum, isn't it?

    its not against the rules to do a little programming now and then and show results of your work.

    if you don't care, thats fine, you don't have to participate in the discussion.


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    webmonkey wrote:
    Where did you learn this?

    learn what? are you talking about the loop? or my joke about java programmers?

    the loop is obvious, webmonkey..what is there not to understand? it does nothing.
    a c compiler won't generate code for that if used properly.

    and the joke is just that..trying to be funny.


  • Advertisement
  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Martyr wrote: »
    learn what? are you talking about the loop? or my joke about java programmers?

    the loop is obvious, webmonkey..what is there not to understand? it does nothing.
    a c compiler won't generate code for that if used properly.

    and the joke is just that..trying to be funny.
    I don't see why a compiler would complain and prevent it from going on its way to assembly, it is syntactically correct, maybe not semantically but definitely syntactically. Have you ever tried it? - I'm still wondering where you learned it?


  • Registered Users Posts: 515 ✭✭✭NeverSayDie


    Webmonkey wrote: »
    I don't see why a compiler would complain and prevent it from going on its way to assembly, it is syntactically correct, maybe not semantically but definitely syntactically. Have you ever tried it? - I'm still wondering where you learned it?

    Modern compilers do all sorts of optimisation in the process of turning high level code into machine code. It won't complain, it'll just rearrange things to work faster. Ditching clearly redundant stuff like empty loops would be an example. See here for all sorts of crazy detail on the topic, if you're into that kind of thing;
    http://en.wikipedia.org/wiki/Compiler_optimization

    Re where he learnt it, possibly here;
    http://www.javaperformancetuning.com/news/qotm028.shtml
    http://www.javaperformancetuning.com/news/qotm029.shtml


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Modern compilers do all sorts of optimisation in the process of turning high level code into machine code. It won't complain, it'll just rearrange things to work faster. Ditching clearly redundant stuff like empty loops would be an example. See here for all sorts of crazy detail on the topic, if you're into that kind of thing;
    http://en.wikipedia.org/wiki/Compiler_optimization

    Re where he learnt it, possibly here;
    http://www.javaperformancetuning.com/news/qotm028.shtml
    http://www.javaperformancetuning.com/news/qotm029.shtml
    I'm not referring to Java, I'm referring to the statement of "most compilers", the GNU C compiler for example, especially since he making out C/C++ is faster than Java :pac: - Sorry I should have made it clearer.

    Thanks for the links however, I am into that sort of thing :pac:


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    Re where he learnt it, possibly here;

    no, i didn't see that page before.
    webmonkey wrote:
    I'm not referring to Java, I'm referring to the statement of "most compilers", the GNU C compiler for example, especially since he making out C/C++ is faster than Java - Sorry I should have made it clearer.

    yes, C/C++ is faster imho, would you like to prove me wrong? won't hold my breath :)

    if java compensates for being a **** programmer, why can't c/c++ compilers do the same?
    webmonkey wrote:
    Thanks for the links however, I am into that sort of thing

    hmm, i've a feeling theres alot of you expert programmers insecure about the end result of going against a noob like myself.

    i'm not afraid of being proved wrong here, but i know i'm right ;)

    put your money where your mouth is, webmonkey..or any of ye for that matter :P


  • Registered Users Posts: 515 ✭✭✭NeverSayDie


    Martyr wrote: »
    hmm, i've a feeling theres alot of you expert programmers insecure about the end result of going against a noob like myself.

    i'm not afraid of being proved wrong here, but i know i'm right ;)

    put your money where your mouth is, webmonkey..or any of ye for that matter :P

    Why on earth would anyone here be "insecure" about the end results, unless they'd written the compiler themselves or some such? Maybe you could discuss some of the technical reasons why you know you're right, and make things more useful for the OP?


  • Registered Users Posts: 3,945 ✭✭✭Anima


    Here is a good wikiarticle for java performance, where it is good and bad.

    http://en.wikipedia.org/wiki/Java_performance#Comparison_to_other_languages

    Seems to tie a lot of what I've been reading together.


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    Why on earth would anyone here be "insecure" about the end results, unless they'd written the compiler themselves or some such? Maybe you could discuss some of the technical reasons why you know you're right, and make things more useful for the OP?

    if you give me until sunday night or so, i should have enough time to produce some results on my own using both Java / C or C++

    The reason i wanted an experienced Java programmer is so that there could be no arguement on the results, i'm not experienced writing Java but i'm sure i could cook up something..(i'm not experienced with C/C++ either, but i'm guessing it should be faster than Java anyway)

    Sure, i can write some code in either and show results but chances are some expert on Java will claim to know a way of doing it better..

    i'll do it, just don't have time right now, i'm busy in my call centre :pac: no doubt hobbes,webmonkey and others who disagree with me are programming some huge supercomputer using java or .net...."no time" to prove whether i'm right or wrong, just tell me i'm wrong..


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Martyr wrote: »
    if you give me until sunday night or so, i should have enough time to produce some results on my own using both Java / C or C++

    The reason i wanted an experienced Java programmer is so that there could be no arguement on the results, i'm not experienced writing Java but i'm sure i could cook up something..(i'm not experienced with C/C++ either, but i'm guessing it should be faster than Java anyway)

    Sure, i can write some code in either and show results but chances are some expert on Java will claim to know a way of doing it better..

    i'll do it, just don't have time right now, i'm busy in my call centre :pac: no doubt hobbes,webmonkey and others who disagree with me are programming some huge supercomputer using java or .net...."no time" to prove whether i'm right or wrong, just tell me i'm wrong..
    Why do you assume I am a java expert. I am a C/C++ programmer and I hate working with Java, simply don't like it.

    Where did I try to prove you wrong, I was simply saying that the code presented did not get optimized in my GNU compiler and I did try it.
    However i did notice this:
    for (j = 0; i < cycle1; i++)
        for(j = 0; j < cycle2; j++)
    

    does get optimized while:
    for (i = 0; i < cycle1; i++)
      for (j = 0; j < cycle2; j++)
      {
      }
    

    does not.


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    webmonkey wrote:
    Why do you assume I am a java expert. I am a C/C++ programmer and I hate working with Java, simply don't like it.

    ok, sorry for assuming, but i expected someone programming with C/C++ to know that most C compilers (if used correctly) would not generate machine code for a loop that does nothing.


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    if compiler is used correctly, and i mean using its optimisation features..i don't think either of those loops would generate ANY machine code.

    honestly, where would you see something like this used anyway?

    its a bit of a bogus arguement.no offence, its not a practical example, its not a fair example to say java is better based on a loop like that ..


  • Advertisement
  • Registered Users Posts: 515 ✭✭✭NeverSayDie


    Martyr wrote: »
    if you give me until sunday night or so, i should have enough time to produce some results on my own using both Java / C or C++

    The reason i wanted an experienced Java programmer is so that there could be no arguement on the results, i'm not experienced writing Java but i'm sure i could cook up something..(i'm not experienced with C/C++ either, but i'm guessing it should be faster than Java anyway)

    Sure, i can write some code in either and show results but chances are some expert on Java will claim to know a way of doing it better..

    i'll do it, just don't have time right now, i'm busy in my call centre :pac: no doubt hobbes,webmonkey and others who disagree with me are programming some huge supercomputer using java or .net...."no time" to prove whether i'm right or wrong, just tell me i'm wrong..

    Feel free, but that wasn't what I asked. I was interested in learning about the technical reasoning behind you knowing you're right, not millisecond counts from profiling code snippets.


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Martyr wrote: »
    if compiler is used correctly, and i mean using its optimisation features..i don't think either of those loops would generate ANY machine code.

    honestly, where would you see something like this used anyway?

    its a bit of a bogus arguement.no offence, its not a practical, fair assumption to say java is better based on a loop like that ..
    for (i = 0; i < cycle1; i++)
      for (j = 0; j < cycle2; j++)
      {
      }
    

    This doesn't and it runs away.

    There are times you use loops like this but that include a sleep to cause your program to pause and wait for an interrupt/signal or something.


  • Moderators, Science, Health & Environment Moderators Posts: 10,079 Mod ✭✭✭✭marco_polo


    Martyr wrote: »
    if compiler is used correctly, and i mean using its optimisation features..i don't think either of those loops would generate ANY machine code.

    honestly, where would you see something like this used anyway?

    its a bit of a bogus arguement.no offence, its not a practical example, its not a fair example to say java is better based on a loop like that ..

    It is just a joke example dude, using default options I believe it would take the gcc compiler about a month BTW :D.


  • Registered Users Posts: 3,945 ✭✭✭Anima


    Webmonkey are you using "-O3" when compiling? If there is nothing in the loops, then it should get optimised away.


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Done trick, cheers.


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    Feel free, but that wasn't what I asked. I was interested in learning about the technical reasoning behind you knowing you're right, not millisecond counts from profiling code snippets.

    Its a gamble, based on reading mainly, see the wikipedia entry by Anima.
    its all based on research done so far, by other people of course but i'll try this myself later out of curiosity.

    [PHP]for (i = 0; i < cycle1; i++)
    for (j = 0; j < cycle2; j++)
    {
    }[/PHP]
    webmonkey wrote:
    There are times you use loops like this but that include a sleep to cause your program to pause and wait for an interrupt/signal or something.

    you would use something like that to signal/interrupt? :eek:
    not very sophisticated..but what do i know, i work in a call centre :pac:

    what about this:

    [PHP]
    int cycle1,cycle2;

    cycle1 = 1000;
    cycle2 = 2000;

    for (i = 0; i < cycle1; i++)
    for (j = 0; j < cycle2; j++)
    {
    }[/PHP]

    what compiler are you using? what options?
    marco_polo wrote:
    It is just a joke example dude, using default options I believe it would take the gcc compiler about a month BTW :D

    LOL..maybe if you can't use it properly :D


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    nevermind, Anima answered.

    these options i would normally use for GNU c compiler:

    -fomit-frame-pointer -O3 -fexpensive-optimizations

    also, writing good code helps.

    Agner Fog updates a very good manual on optimizing C++

    located here: http://www.agner.org/optimize/


  • Moderators, Science, Health & Environment Moderators Posts: 10,079 Mod ✭✭✭✭marco_polo


    Martyr wrote: »
    ...
    but what do i know, i work in a call centre :pac:

    Judging from your posts, everything.


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    i do work in a call centre, ask anyone that knows me.

    i'm not a programmer by profession, never have been which is why anyone here should feel comfortable proving that Java is faster than C/C++ at generating machine code.


  • Advertisement
  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Marty wrote:
    you would use something like that to signal/interrupt?
    not very sophisticated..but what do i know, i work in a call centre

    How would you do it so? We talking about using os primitives for handling signal handlers etc. You clearly know what your talking about.


Advertisement