Ada
>real 0m12.542s
>user 0m12.537s
>sys 0m0.007s
C
>real 0m16.949s
>user 0m16.117s
>sys 0m0.830s
Each you heart out
>>53566098
You obviously didn't optimize enough. Make more use of inlining, pointers, and magic numbers.
>>53566098
Your C programming is embarrassing, go take a 101 course and try again.
>>53566098
>-o0
>any time when not debugging
Also
why not call rand once? It outputs more than 2 bytes of randomness.
>>53566273
I used too many magic numbers desu
>>53566341
I used -O2 for both. The point was to just test how two languages handled the exact same function, not how micromanaged efficient I could make the test. I don't think it would change the overall outcome since I could make the same optimization in Ada.
>>53566384
Its not the same function. Your ada one is only getting a single char of randomness per call.
Change the ada one to an int and compare.
>>53566407
>same guy
Just used one random call and then bitwised it and it drops the C time from 17 seconds to 9.
>>53566417
/thread
>>53566098
C loks much nicer. I hate languages having first word lowercase and second word uppercase letters (ie. Java).
>>53566417
If you split up one rand call between 4 ints, it drops the time down to 4.5.for(i = 0; i < ARSIZE; i+=2){
int r = rand();
a[i] = r&255;
a[i+1] = (r>>8)&255;
b[i] = (r>>16)&&255;
b[i+1] = (r>>24)&&255;
c[i] = a[i] + b[i];
c[i+1] = a[i+1] + b[i+1];
}
>>53566453
time ./a.out
real 0m4.685s
user 0m4.684s
sys 0m0.000s
FFS this is probably similar to what the ada rand(char) does internally.
>>53566417
not OP but you're missing >>53566384 's point
it's how the lang handled the exact same function
>>53566472
>exact same function
Then set it to return an int instead of a char.
Compare the times then.
>>53566472
Random(G) is not the same as rand()&255.
>>53566541
using https://stackoverflow.com/questions/26237419/faster-than-rand and then using bitwise shifts to get it to output to both a and b results in times less than 2 seconds.
>>53566098
As always OP is a confirmed retard.
>>hurr durr, they're bother rand
If you think they are the same function then you truly are special.
The only thing embarrassing here is what you did — I can't actually believe someone could be special enough to think you could benchmark a language using two functions that don't even use the same underlying method.
>>53566467
OP and C-haters BTFO once again
>>53566417
Back. I dropped my Ada code down to one Random call and used bitwise to get the values for A and B. Surprise, it dropped to 6sec flat. No I didn't bother doing 4 bitwise operations like >>53566453 because I think it's clear rand() is just not as good as Discrete_Random.
>>53566734
So what you're saying is that I can't compare two different algorithms if the steps aren't the same, but the end result is equivalent. Got it.