Govind 5
Govind 5
Practical-05
Aim: Write a program to check task distribution using Gprof.
What is Gprof?
Gprof is a GNU profiler used to analyze program performance. It provides detailed insights into
the time spent in each function, the number of times each function is called, and the relationships
between functions. Profiling helps identify performance bottlenecks, optimize code, and ensure
efficient task distribution.
add();
return 0;
}
void add()
{
int a,b,c,d;
printf("\nEnter The Two values:");
scanf("%d%d",&a,&b);
c=a+b;
d=a-b;
printf("Addition:%d\n",c);
printf("Substraction:%d",d);
}
Output:
Source code:
%%writefile govind_5.2.c
#include <stdio.h>
#include <time.h>
void perform_computation() {
int main() {
clock_t start, end;
double elapsed_time;
start = clock();
printf("Starting computation...\n");
return 0;
}
Output:
Conclusion: Task Distribution: The profiling report shows how much time each function (task)
takes.
Bottleneck Identification :If one task is disproportionately time-consuming, consider optimizing it
or parallelizing tasks.
Improved Efficiency: By focusing optimization efforts on high-time-consuming tasks, you can
reduce overall runtime and improve resource utilization.
Practical Usage: This process is invaluable in large-scale applications like database systems,
simulations, or any software requiring performance optimization.