DEV Community

loading...

Performance Measurement

221910304050 profile image Samanvi Thota ・1 min read

Performance Measurement: It is based on space and time requirements of a particular algorithm. These quantities depend on the compiler and options used, and the system on which the algorithm runs. The space and time needed for compilation are important during program testing. To obtain the run time of a program, we need a clocking procedure. We assume the existence of a program GetTime() that returns the current time in milliseconds.

Suppose if we want to measure the worst-case performance of the sequential search algorithm
we need to follow these:
1.decide on the values of n for which the times are to be obtained
2.determine for each of the above values of the data that exhibit the worst-case behavior.

Algorithm:
SeqSearch(a,x,n)
//search for x in a[1:n]. a[0] is used as additional space.
{
i:=n; a[0] :=x;
while (a[i]=!x) do i := i-1;
return i;
}

click here, for more detailed explanation with example

Discussion (1)

Collapse
guntakalikhitha profile image
Forem Open with the Forem app