When you are testing your software, you may find that the program is taking too much time for execution. Before optimizing the code, you need to study how much time each segment of the program is taking. To measure the time taken to execute a portion of a program is important for many applications such as embedded software development, communication protocol development etc. This is useful while carrying out simulation studies of algorithms to be implemented on the embedded system. In addition, the timing analysis gives valuable information as to which portions of the code are taking longer time, so that the code can be optimized, or a more efficient algorithm can be chosen to improve the speed.
In C language, the functions time() and clock() are used to measure the time taken by the program segments. We will illustrate the use of these functions through two examples. Listing shows the use of time() function.
Listing ttiming.c 7
Here are the important aspects of this program:
You can compare the CPU time obtained through the time function and the time command of the shell. They will be approximately same.
The following program, given in Listing 10.2 illustrates the clock() function call. Note that clock does not give the time in seconds, but in clock ticks. The number of ticks in a second is obtained using the parameter CLOCKS_PER_SEC.
This program is similar to the preceding program in which we used the time function. Here are the differences:
The timings obtained from the clock function and the shell command time will be approximately the same.
Note: While doing peiformance testing of software, you may realize that the execution time for the total program is very high. You need to find out which portions of the program are taking long time. For thiS' the timing functions are of immense use.
Testing Tools Related Interview Questions
|LoadRunner Interview Questions||QTP Interview Questions|
|Agile Testing Interview Questions||Manual Testing Interview Questions|
|Quality Management Interview Questions||Quality Control Interview Questions|
|Selenium Interview Questions||Qlik View Interview Questions|
|Bugzilla Bug Tracking System Interview Questions||Software testing Interview Questions|
|Test Cases Interview Questions||Performance Testing Interview Questions|
|Test Estimation Interview Questions||Test Manager Interview Questions|
|Qlik Sense Interview Questions||Test Director Interview Questions|
|Mantis Bug Tracking Interview Questions||Test Plan Interview Questions|
|Defect Reporting Interview Questions||Test Complete Interview Questions|
Testing Tools Related Practice Tests
|LoadRunner Practice Tests||QTP Practice Tests|
|Agile Testing Practice Tests||Manual Testing Practice Tests|
|Quality Management Practice Tests||Quality Control Practice Tests|
|Selenium Practice Tests||Qlik View Practice Tests|
|Bugzilla Bug Tracking System Practice Tests||Software testing Practice Tests|
|Performance Testing Practice Tests|
Testing Tools Tutorial
Software Qualityassurance An Overview
Software Testing Process
Software Testing Tools An Overview
Source Code Testing Utilities In Unix/linux Environment
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.