When does a func() become too large?

This is a discussion on When does a func() become too large? within the C++ Programming forums, part of the General Programming Boards category; You should use a profiler to find the bottlenecks when you've finished your program. It's the fastest and easiest way....

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,635
    You should use a profiler to find the bottlenecks when you've finished your program. It's the fastest and easiest way.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Don't forget most reliable.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #18
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Location
    Hampton, VA
    Posts
    391
    Quote Originally Posted by Elysia View Post
    You should use a profiler to find the bottlenecks when you've finished your program. It's the fastest and easiest way.
    Forget my ignorance and do pray tell, what is this profiler in which you speak of?
    Ubuntu Desktop
    GCC/G++
    Geany (for quick projects)
    Anjuta (for larger things)

  4. #19
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    A profiler is a system that tracks the execution of your program to find out where it spends its time.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #20
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    A profiler is a piece of software that measures the amount of time, number of calls or similar that a particular piece of code is used.

    There are two forms of profilers:
    1. Sampling profiler - oprofile, vtune for example.
    This method installs some extra code in certain interrupt(s) to capture where the code is executing when the interrupt is taken [and in modern processors also take advantage of "performance counters"], and can non-intrusively show pieces of code that are "heavy" on the CPU.
    2. Intrusive profiler - gprof for example.
    This method adds extra code to indicate which parts of the code is performed how many times. Obviously this is only necessary on basic blocks [that is, any code that has a jump to or from it, so loops and conditional code], so not every line of source code need instrumenting. But the additional code does change the behaviour of the code itself, and in small functions, it may double or triple the execution time - but you do get a very exact number of calls to the function, etc.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #21
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Also, under C++, the intrusive profilers typically need compiler support, while the sampling profilers don't. To use gprof, you need to compile and link your program with the -pg GCC option.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #22
    Use this: dudeomanodude's Avatar
    Join Date
    Jan 2008
    Location
    Hampton, VA
    Posts
    391
    sounds cool, i'll give them a try.
    Ubuntu Desktop
    GCC/G++
    Geany (for quick projects)
    Anjuta (for larger things)

  8. #23
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,243
    Quote Originally Posted by dudeomanodude View Post
    Ha, is that the rule of thumb? I was kind of hoping for a more insightful answer than that.
    It's about as insightful as you're going to get.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [Large file][Value too large for defined data type]
    By salsan in forum Linux Programming
    Replies: 11
    Last Post: 02-05-2008, 03:18 AM
  2. Representing a Large Integer with an Array
    By random_accident in forum C Programming
    Replies: 3
    Last Post: 03-03-2005, 07:56 PM
  3. typedef a func
    By trekker in forum C Programming
    Replies: 4
    Last Post: 07-02-2002, 05:15 AM
  4. Delete & print func()
    By spentdome in forum C Programming
    Replies: 5
    Last Post: 05-29-2002, 09:02 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21