Vous êtes sur la page 1sur 4

Computer Programming

What are important factors which affect the


running time of a program?
Anyone can help me list out all of them?

5 ANSWERS

Deeksha Jain
Written 98w ago

Some of the factors that affect the speed of execution are:

1. Parallelism of the Program:


A multi-threaded program that is running on multicore machine will be faster.
Sometimes certain number of threads work best for x-core machine. So try
different thread numbers to understand this.

2. CPU utilisation
   Tool to measure  : top on Linux
You could check if the program is cpu bound by running "top" on linux.

3. I/O bound
    Tool to measure  : iostat on Linux
Sometimes a program is IO bound, due to disk reads etc, you could check this
on linux with iostat command.

4. Overhead due to many function calls:


    Tool to measure  : GNU gprof on Linux , Callgrind
There could be a huge overhead on running if a function call is made multiple
times for a small function. This could be checked using Profiler like GNU
gprof for C. Inline functions that are called many times to avoid the stack
overhead.

5. Recursion:
Recursion can cause a lot of overhead, if the structure of function permits,
then use tail recursion, to avoid the stack overhead.

6. Language Choice:
C is faster when compare to Java because it is low level language. Thus
many network security applications are written in C, where speed matters.
Sign In
configuration might work best for it.

8. Contention:
If there are multiple threads, they are synchronised to access common
resources, then there can be contention for the resources, which causes
threads to wait.

9. Buggy Synchronization:
   Tools to detect: Helgrind
If there are deadlocks, the program will stop working or the two threads
involved in deadlock will stop. Helgrind is a brilliant tool that you could use to
detect potential deadlocks, data race conditions, misuse of posix thread API.
3.6k Views · View Upvotes

Share

MORE ANSWERS BELOW. RELATED QUESTIONS

What causes run time errors in a C++ programs?


5,929 Views

How can I calculate the running time of a program?


1,247 Views

How can I decrease my program's running time in C++?


564 Views

Why does the program below cause a run time error?


592 Views

Which is more important for a programming language, development speed, or


running speed?
1,528 Views

How do I find the run time of a program for programming contests?


8 Views
Sign In
package instead of a specific class?
3,647 Views

What is the best way to describe compile time and run time difference for a
program?
147 Views

What are the factors that affect the selection of a programming language for
a large scale software project?
535 Views

What is the compile time constant and run time constant in the C
programming language?
687 Views

Learning to Program: What is the difference between run time error and
compilation error?
2,875 Views

Do dynamic memory allocations, affect the execution time of a C program?


11,581 Views

Is there a tool for exploring a program’s run-time behavior visually in Java?


818 Views

Why do simple programs often take a long time to run?


2,184 Views

How would I create a message in Lua that only runs the first time the
program is run?
866 Views

OTHER ANSWERS

Tim Hofstetter, Software Engineer since 1985


Written 100w ago

CPU speed, memory load versus available RAM, available cache size, hard
drive speed (if file-system-intensive), network speed (if network-intensive),
(various) bus speed, code optimization, compiled versus interpreted,
onscreen feeback display versus "running silent", hard drive fragmentation (if
Sign In

Share

Vous aimerez peut-être aussi