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

Pages: 1-

Why profile code?

Name: Anonymous 2009-10-03 9:04

What's the point of profilers?  If I have written the code, I know which points are slow, and which do not matter.

Name: Anonymous 2009-10-03 9:19

Actually, you don't know where the points are slow. Profilers exist so you can profile where and how long your programs operate.

Name: Anonymous 2009-10-03 9:37

>>2
Actually, you don't know where the points are slow.
Is that what people really think?

Name: Anonymous 2009-10-03 9:45

>>3
Unless you've got an intimate knowledge of what your compiler is doing, you're not going to have a excellent idea of how slow/quickly your program works without a profiler. The best you can do is an educated guess.

Name: Anonymous 2009-10-03 10:00

This is how easy it is to troll prog now?

Name: Anonymous 2009-10-03 10:04

>>4
i = 0;
for (i = 0; i < 100; ++i) {
    j = i + 10;
}
print j;


Using this as an example (well, with some higher numbers, and assuming print takes 0 time), I can see that the loop part is the slowest part of the code.  I furthermore know that loops are bad, so I devise a way to calculate j without looping.  Perhaps I can even replace the loop by a constant value.

Name: Anonymous 2009-10-03 10:41

>>6
Now try estimating the performance of a complete computer program. Let's take Supertux as an example.

Name: Anonymous 2009-10-03 10:54

>>7
I did not write that program, and that program uses a lot of external libraries which makes it impossible to tell how much a library call costs.  In such a case a profiler might be useful, but that is a very rare exception.

Name: Anonymous 2009-10-03 12:12

>>6
~ $ cat crap.c
#include <stdio.h>

int main()
{
    int j = 0;
    for(int i = 0; i < 100; ++i)
        j = i + 10;
    printf("%d\n", j);
}
~ $ gcc -std=c99 -O3 -Wall -Wextra -pedantic crap.c -S -masm=intel
~ $ cat crap.s
    .file    "crap.c"
    .intel_syntax noprefix
    .section    .rodata.str1.1,"aMS",@progbits,1
.LC0:
    .string    "%d\n"
    .text
    .p2align 4,,15
.globl main
    .type    main, @function
main:
    push    ebp
    mov    ebp, esp
    and    esp, -16
    sub    esp, 16
    mov    DWORD PTR [esp+4], 109
    mov    DWORD PTR [esp], OFFSET FLAT:.LC0
    call    printf
    xor    eax, eax
    leave
    ret
    .size    main, .-main
    .ident    "GCC: (GNU) 4.4.1"
    .section    .note.GNU-stack,"",@progbits


Replace 109 with 5950 if you meant j += ...
IHBT

Name: Anonymous 2009-10-03 12:28

>>5
Welcome to 2009, where have you been for all these years?

Name: Anonymous 2009-10-03 14:07

Yeah, this one was terrible.

Name: Anonymous 2009-10-03 17:25

>>8
Working on others' code is an exception.
Using libraries is rare.
This is what toy language programmers really believe.

Name: Anonymous 2009-10-03 18:04

>>12
Well, if you are using libraries you can't very well optimize them, now can you?

Real men reinvent the wheel at least once a day.

Name: Anonymous 2009-10-03 18:28

profile my anus

Name: Anonymous 2011-02-03 6:09


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