Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Sepples: a blast from the past

Name: Anonymous 2008-07-21 17:31


deque<long> test_values;
// Fill test_values with 1000000 random numbers
stack<long> test_stack;
clock_t t1 = clock();
deque<long>::iterator j = test_values.begin();
const deque<long>::iterator e = test_values.end();
while(j != e) {
    test_stack.push(*j);
    ++j;
}
clock_t t2 = clock();

Mean (t2-t1) over a couple of runs gives about 13000
But change the prefix op with a post-fix op:
while(j != e) {
    test_stack.push(*j++);
}

and the mean shoots up to 18000. /prog/, I ask you this: Why the fuck does it cost so much to store an additional integer?
ಠ_ಠ

Name: Anonymous 2008-11-12 5:55

>>16

Don't make me compile that manually, you fucking cuntnigger. Give assembly!

Anyway, for GCC 3.4.4, there are no fucking differences between both versions. Both of them generate:

no optimizations:
    pushl    %ebp
    movl    %esp, %ebp
    subl    $8, %esp
    andl    $-16, %esp
    movl    $0, %eax
    addl    $15, %eax
    addl    $15, %eax
    shrl    $4, %eax
    sall    $4, %eax
    movl    %eax, -4(%ebp)
    movl    -4(%ebp), %eax
    call    __alloca
    call    ___main
    incl    8(%ebp)
    movl    $0, %eax
    leave
    ret

-O2:
    pushl    %ebp
    movl    $16, %eax
    movl    %esp, %ebp
    subl    $8, %esp
    andl    $-16, %esp
    call    __alloca
    call    ___main
    leave
    xorl    %eax, %eax
    ret

-Os:
    pushl    %ebp
    movl    %esp, %ebp
    call    ___main
    popl    %ebp
    xorl    %eax, %eax
    ret

So, there. I demand an explanation for this bullshit.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List