CPU time
≈ 4 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
CPU time (or process time) is the amount of time that a central processing unit (CPU) was used for processing a specific set of instructions of a computer program or operating system, as opposed to total time from start to finish, where the CPU might have spent time on other processes. See the figure. CPU time is measured in clock ticks or seconds. Sometimes it is useful to convert CPU time into a percentage of the CPU capacity, giving the CPU usage. Measuring CPU time for two functionally identical programs that process identical inputs can indicate which program is faster, but it is a common misunderstanding that CPU time can be used to compare algorithms. Comparing programs by their CPU time compares specific implementations of algorithms. (It is possible to have both efficient and inefficient implementations of the same algorithm.) Algorithms are more commonly compared using measures of time complexity and space complexity. Typically, the CPU time used by a program is measured by the operating system, which schedules all of the work of the CPU. Modern multitasking operating systems run hundreds of processes. (A process is a running program.) Upon starting a process, the operating system records the time using an internal timer. When the process is suspended or terminated, the operating system again records the time.…
CPU time (or process time) is the amount of time that a central processing unit (CPU) was used for processing a specific set of instructions of a computer program or operating system, as opposed to total time from start to finish, where the CPU might have spent time on other processes. See the figure. CPU time is measured in clock ticks or seconds. Sometimes it is useful to convert CPU time into a percentage of the CPU capacity, giving the CPU usage. Measuring CPU time for two functionally identical programs that process identical inputs can indicate which program is faster, but it is a common misunderstanding that CPU time can be used to compare algorithms. Comparing programs by their CPU time compares specific implementations of algorithms. (It is possible to have both efficient and inefficient implementations of the same algorithm.) Algorithms are more commonly compared using measures of time complexity and space complexity. Typically, the CPU time used by a program is measured by the operating system, which schedules all of the work of the CPU. Modern multitasking operating systems run hundreds of processes. (A process is a running program.) Upon starting a process, the operating system records the time using an internal timer. When the process is suspended or terminated, the operating system again records the time. The total time that a process spent running is its CPU time, as shown in the figure. $ gcc nextPrimeNumber.c -o nextPrimeNumber -lm $ /usr/bin/time ./nextPrimeNumber 300000070034 Prime number greater than 300000070034 is 300000070043 0.01user 0.00system 0:00.01elapsed 100%CPU $ This process took a total of 0.02 seconds of CPU time (User + System). The reported System time is 0.00 seconds, indicating that the amount of System time used was less than the printed resolution of 0.01 seconds. Elapsed real time was 0.08 seconds. The following is the source code of the application nextPrimeNumber which was used in the above example. // nextPrimeNumber.c include include include int isPrimeNumber(unsigned long int n) { unsigned long int limit = ceil(sqrt(n)); for (int i = 2; i
Text derived from https://en.wikipedia.org/w/index.php?oldid=1339242959 under CC BY-SA 4.0; modifications have been made.