{"id":1314,"date":"2018-01-13T10:32:13","date_gmt":"2018-01-13T08:32:13","guid":{"rendered":"https:\/\/community.virtono.com\/?p=1314"},"modified":"2020-06-10T16:41:10","modified_gmt":"2020-06-10T13:41:10","slug":"linux-analysis-of-execution-time-with-time","status":"publish","type":"post","link":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/linux-analysis-of-execution-time-with-time\/","title":{"rendered":"Linux analysis of execution time with time"},"content":{"rendered":"<p>On Linux, the\u00a0<b>time<\/b>\u00a0command can be used to measure the execution time for a command line program.\u00a0This article shows this with the example of the updatedb program.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/linux-analysis-of-execution-time-with-time\/#call\" title=\"call\">call<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/linux-analysis-of-execution-time-with-time\/#analysis\" title=\"analysis\">analysis<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"call\"><\/span><span id=\"Aufruf\" class=\"mw-headline\">call<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The\u00a0<code>time<\/code>command is simply given before the program to be executed when calling:<\/p>\n<pre>[root @ tpw ~] # time updatedb\r\n\r\nreal 1m5.682s\r\nuser 0m0.543s\r\nsys 0m2.823s\r\n[root @ tpw ~] # \r\n<\/pre>\n<p>The program updatedb is a nice example here.\u00a0It searches the\u00a0<i>entire<\/i>\u00a0file system for all files and writes the information to a small database.\u00a0With the help of this database you can search for files later with the locate commands.\u00a0This search is much faster than a normal search with the find command.\u00a0However, the result does not reflect the current state, but the state of the database (last call of the updatedb command).<\/p>\n<p>Since udpatedb searches the entire file system, resulting in very random I \/ O accesses, the CPU waits most of the time for I \/ O when updatingb is executed.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"analysis\"><\/span><span id=\"Analyse\" class=\"mw-headline\">analysis<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The individual values have the following meaning:<\/p>\n<ul>\n<li><b>real<\/b>\u00a0:\u00a0<i>Elapsed real time<\/i>\u00a0&#8211; the total actual execution time.<\/li>\n<li><b>user<\/b>\u00a0:\u00a0<i>Total number of CPU-seconds that the process spent in user mode<\/i>\u00a0&#8211; ie the time in which the CPU actually executes the (user) code of the program.<\/li>\n<li><b>sys<\/b>\u00a0:\u00a0<i>Total number of CPU-seconds that the process spent in kernel mode<\/i>\u00a0&#8211; the time when the CPU is busy executing kernel code for the program.<\/li>\n<\/ul>\n<p>The rest of the time the CPU spends either with other programs or waiting for I \/ O.\u00a0This also shows a parallel executed vmstat\u00a0,Example: CPU waits for IO\u00a0:<\/p>\n<pre>[user @ tpw ~] $ vmstat 1 10\r\nprocs ----------- memory ---------- --- swap-- ----- io ---- --system-- ----- cpu -----\r\n rb swpd free buff cache si so bi bo in cs us sy id wa st\r\n 3 1 3276 17544 109672 869900 0 0 62 180 812 1340 17 6 \u200b\u200b75 2 0\t\r\n 1 1 3276 17000 110144 869900 0 0 464 76 815 1594 17 5 0 78 0\t\r\n 2 1 3276 16556 110552 869892 0 0 408 20 670 1415 2 5 0 93 0\t\r\n 0 1 3276 15980 111060 869936 0 0 508 0 844 1775 9 6 0 85 0\t\r\n 1 1 3276 15408 111524 869944 0 0 464 0 717 1592 5 4 0 91 0\t\r\n 0 1 3276 15000 111904 869976 0 0 372 12 627 1461 2 5 0 93 0\t\r\n 0 1 3276 15700 112788 869956 0 0 876 40 960 2177 5 7 0 88 0\t\r\n 0 1 3276 14420 113968 870136 0 0 1180 28 850 2020 5 11 0 84 0\t\r\n 0 1 3276 14628 115560 868288 0 0 1600 0 1281 2602 3 17 0 80 0\t\r\n 0 1 3276 14744 116996 866704 0 0 1696 0 1426 2806 7 19 0 74 0\t\r\n[user @ tpw ~] $<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>On Linux, the\u00a0time\u00a0command can be used to measure the execution time for a command line program.\u00a0This article shows this with the example of the updatedb program. call The\u00a0timecommand is simply given before the program to be executed when calling: [root @ tpw ~] # time updatedb real 1m5.682s user 0m0.543s<\/p>\n","protected":false},"author":4,"featured_media":1315,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[3],"tags":[],"class_list":["post-1314","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorial-how-to"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2018\/01\/after_zoom_fit.png?fit=1920%2C1080&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7ISfL-lc","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":2164,"url":"https:\/\/www.virtono.com\/community\/knowledgebase\/manage-linux-package-managers-with-the-shell\/","url_meta":{"origin":1314,"position":0},"title":"Manage Linux package managers with the shell","author":"Shreyash Sharma","date":"December 19, 2020","format":false,"excerpt":"Package management via the Advanced Package Tool, or APT for short, is part of the recipe for success of Debian and thus also of offshoots such as Ubuntu.\u00a0There are plenty of graphical interfaces for this, but APT can only take advantage of all its advantages in the shell. Installing and\u2026","rel":"","context":"In &quot;Knowledgebase&quot;","block_context":{"text":"Knowledgebase","link":"https:\/\/www.virtono.com\/community\/category\/knowledgebase\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/12\/installing-linux-apps-package.png?fit=640%2C412&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/12\/installing-linux-apps-package.png?fit=640%2C412&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/12\/installing-linux-apps-package.png?fit=640%2C412&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":1795,"url":"https:\/\/www.virtono.com\/community\/knowledgebase\/10-linux-basic-commands-every-user-should-know\/","url_meta":{"origin":1314,"position":1},"title":"10 Linux Basic Commands Every User Should Know","author":"Shreyash Sharma","date":"July 31, 2020","format":false,"excerpt":"Linux can be daunting to some, especially if you have seen people working only through the terminal. Trust me, its not as complicated as it seems neither is it that hard to learn. The only issue is manufacturers do not Linux with their systems. What is Linux? The entire family\u2026","rel":"","context":"In &quot;Knowledgebase&quot;","block_context":{"text":"Knowledgebase","link":"https:\/\/www.virtono.com\/community\/category\/knowledgebase\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/07\/7rQQixjPnrQv.png?fit=640%2C363&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/07\/7rQQixjPnrQv.png?fit=640%2C363&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/07\/7rQQixjPnrQv.png?fit=640%2C363&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":1920,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/wordpress-tutorial-installing-wordpress-manually\/","url_meta":{"origin":1314,"position":2},"title":"WordPress Tutorial -Installing WordPress Manually on a VPS","author":"Shreyash Sharma","date":"September 16, 2020","format":false,"excerpt":"This tutorial is a part of series of articles on WordPress: Understanding WordPressInstalling and Setting up WordPress on VirtonoInstalling WordPress ManuallyNavigating in WordPress DashboardPublishing ContentInstalling WordPress PluginsInstalling WordPress ThemesOptimizing WordPress PerformanceKeeping WordPress Secure You should try this tutorial by getting a Cloud VPS from here. This will help you in\u2026","rel":"","context":"In &quot;Knowledgebase&quot;","block_context":{"text":"Knowledgebase","link":"https:\/\/www.virtono.com\/community\/category\/knowledgebase\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/09\/install-wordpress-with-apache-on-centos-8-1.jpg?fit=1024%2C512&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/09\/install-wordpress-with-apache-on-centos-8-1.jpg?fit=1024%2C512&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/09\/install-wordpress-with-apache-on-centos-8-1.jpg?fit=1024%2C512&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/09\/install-wordpress-with-apache-on-centos-8-1.jpg?fit=1024%2C512&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":3225,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-find-the-largest-files-in-linux\/","url_meta":{"origin":1314,"position":3},"title":"How to find the largest files in Linux","author":"George B.","date":"April 12, 2023","format":false,"excerpt":"When you have a server with 1TB of disk space and your storage is 80% full, it is important to find out which files(largest files) are taking up the most space on your system. This can be done by identifying the biggest files on your system and deleting or moving\u2026","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/www.virtono.com\/community\/category\/tutorial-how-to\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/04\/How-to-find-largest-files-linux.png?fit=600%2C330&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/04\/How-to-find-largest-files-linux.png?fit=600%2C330&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/04\/How-to-find-largest-files-linux.png?fit=600%2C330&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":3432,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-install-django-on-linux\/","url_meta":{"origin":1314,"position":4},"title":"How to Install Django on Linux","author":"George B.","date":"May 31, 2023","format":false,"excerpt":"If you're a Linux user and want to dive into Django development, this step-by-step guide will walk you through the installation of Django on Linux process. Django is a powerful and popular web framework for building robust and scalable web applications. By the end, you'll have Django up and running\u2026","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/www.virtono.com\/community\/category\/tutorial-how-to\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/05\/How-to-Install-Django-on-Linux.png?fit=600%2C330&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/05\/How-to-Install-Django-on-Linux.png?fit=600%2C330&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/05\/How-to-Install-Django-on-Linux.png?fit=600%2C330&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":3875,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/linux-how-to-search-text-in-a-pdf-file-via-command-line\/","url_meta":{"origin":1314,"position":5},"title":"Linux: How to search text in a PDF file via Command Line","author":"George B.","date":"September 15, 2023","format":false,"excerpt":"In this tutorial, we will explain how to search text in a PDF file using Linux command-line options. One of Linux's many advantages is its command-line interface (CLI), which allows users to complete difficult tasks using short, text-based commands. Linux Basics It's essential to understand what a PDF file is\u2026","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/www.virtono.com\/community\/category\/tutorial-how-to\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/09\/How-to-search-text-in-a-PDF-file-via-Command-Line.png?fit=360%2C240&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts\/1314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/comments?post=1314"}],"version-history":[{"count":1,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts\/1314\/revisions"}],"predecessor-version":[{"id":1316,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts\/1314\/revisions\/1316"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/media\/1315"}],"wp:attachment":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/media?parent=1314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/categories?post=1314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/tags?post=1314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}