Interface for evaluating function execution time in shell scripts

Source: Internet
Author: User
Keywords scripts evaluation functions execution time
Tags aliyun code developers file function functions help html

Ksh_timer is designed to help Ksh or ksh93 script Administrators or http://www.aliyun.com/zixun/aggregation/7155.html "> developers to compute each function and its shell The time spent in the script user-defined section.

The following points define the features of the Ksh_timer:

If you run a script in Ksh_timer, the function called by the script is timed automatically. The user uses the # #KTB <section_name> (the beginning of this section) and the # #KTE <section_name> (the end of this section) to define the relevant section in the Script Center. The time given is the total elapsed time, not the time used. The output includes «main» time, which is the total elapsed time of the script. It also includes an unknown output time, which is the time spent in the «main» part of the function or user-defined part. The unknown time also includes the ksh_timer overhead caused by the calculated function. Ksh_timer supports the execution of Ksh and ksh93 scripts. Usage: Ksh_timer [-d] [-c] [-?] [-S] [Script name arguments ...] -D puts Ksh_timer in debug mode. -C retains the original output file (ksh_timer.<script_name>.<pid>.out). Usually deleted after execution. -S [script name arguments ...] scripting file name and required parameters for the script. -? Print usage.

Important Tips

This interface (Ksh_timer) is provided for the convenience of the user. This article uses a sample program to illustrate the usage and functionality of Ksh_timer, which are provided as is, and we do not provide any warranty and support.

The tool has been tested on ibm®aix®5.3,6.1 and version 7.1. Ksh_timer can be used with other operating systems, to do this, you must rebuild the Ksh_timer_c executable for that operating system using the source code provided in the installation section of this article.

Overview

At startup, Ksh_timer reads the input script provided by the command line and constructs the following 3 files (source, timer, and exec files).

The source file contains the original function definition and comes from the exec file. The timer file contains a wrapper function that includes the timing code and calls the original function. The timer file also comes from the exec file. In the following example, the original function F1 is renamed to F1_orig in the source file, and in the timer file, F1 has a timing code containing the F1_orig function, which allows us to get the time that the original function F1. The exec file is the source file and the timer file, and contains the original main code and the timer code for any user-defined part.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.