From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29104 invoked by alias); 13 Jul 2016 21:29:44 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21768 Received: (qmail 22178 invoked from network); 13 Jul 2016 21:29:44 -0000 X-Qmail-Scanner-Diagnostics: from mail-pf0-f174.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.192.174):SA:0(0.0/5.0):. Processed in 0.140321 secs); 13 Jul 2016 21:29:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at brasslantern.com does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=5/4WMPYD7daGj0tqGuV+d8gjCB5MRxKXFQne2COqCsU=; b=BYN/KX5iym8jbYEyZPExPyLSEt0NxdPPOliFJ9+b+RzY2qH97yXuqYNwiVulSwzOmo d7FOPA+11f+9QhGuQ3osEvBqpBJalGdTR1qpjUzpTf2tpo4MZsVMPlrAvAniP9I3OM9Z gk986yy7/fefm01bSVyDGJcvz9iB5zeNgoGYV1omm1BoaAaPu2B+ztxmjH83r/Ew9+Ko vpkWm7c0eleTVRzu1xc8bnor59w2DOJadf1CQ7KxB1SUH7UAfCdJdqkZbifhGMNnAb7D I6bSHznpWoDzzpiYTF03L8VbFuEccWWX4dJRt9qOj/tSPGu9RmxqWeOHLPxAd5qATDab QT+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=5/4WMPYD7daGj0tqGuV+d8gjCB5MRxKXFQne2COqCsU=; b=M//2ineDCiN0+SzFO34BhhE0CfSlJf14jxs5GE0jR+XVsU1CQYKeUfYAVUnbvd3uq0 UATUJN4sETvI887eEbZoEDnqGG4mKOxXjocHByZcPgZZz8rvrAHkV8EL2/5bIolviigB jn93xKE+GB2eMgLkxXwISbsDp3aiXv+xzG2hizudOPhXNtXeYO2txlVOfNfF8ZEHGvfh qMacmbrpQ7sLrjIU0Dg05p8WOy8wFXksyJCr36Nz4qYjZ7kherwrKb0UjtZgBeav+qrH HARrlhfya99/yQTk/kG2vSjLetN4g0RorS9nzdez7YnyHtkP5SAaNuHxWQbn5Od342jG co3Q== X-Gm-Message-State: ALyK8tK1FMR2cuRu179J7VkQu7nBKfMw6THWlsxK8Vi3XABtOjAUye4xiOdgp1NXr55Gqw== X-Received: by 10.98.37.71 with SMTP id l68mr7150518pfl.38.1468445376905; Wed, 13 Jul 2016 14:29:36 -0700 (PDT) From: Bart Schaefer Message-Id: <160713142959.ZM21895@torch.brasslantern.com> Date: Wed, 13 Jul 2016 14:29:59 -0700 In-Reply-To: Comments: In reply to Filipe Silva "Re: profile prompt rendering time" (Jul 13, 4:31pm) References: <160713110843.ZM21443@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: profile prompt rendering time MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jul 13, 4:31pm, Filipe Silva wrote: } } Hi, Bart. thanks for the help. I can work with the execution time of ls } included, no problem. If you use precmd + zle-line-init then you don't need to. Just saying. } But I did not really understand where I have to declare SECONDS. Anywhere in your .zshrc or similar init file, or at the command line, as long as it happens before the first event for which you want to get the timings. } See if I understand correctly. I'll open my zshrc and type this: } } ``` } preexec() { } float SECONDS } } } precmd() { } print $SECONDS } } } ``` } } is that right? Not quite. To spell out the example: float SECONDS preexec() { print BEFORE COMMAND: $SECONDS } precmd() { print BEFORE PROMPT: $SECONDS } zle-line-init() { zle -M "AFTER PROMPT: $SECONDS" } zle -N zle-line-init This will give e.g.: torch% echo hello BEFORE COMMAND: 7.365769200e+01 hello BEFORE PROMPT: 7.365787900e+01 torch% AFTER PROMPT: 7.365904200e+01 You don't really need both preexec and precmd, I included them to show the difference. You DO need zle-line-init, there's no other place to read the clock immediately after the prompt is displayed. } Also, is 4.800e+2 = 480 milliseconds? $SECONDS is the elapsed time in seconds since the shell started. So you have to subtract to get the delta. Maybe this is better: float START SECONDS precmd() { START=$SECONDS } zle-line-init() { zle -M "ELAPSED: $((SECONDS - START)) seconds" } Silly example to demonstrate: torch% setopt promptsubst; PS1='$(sleep 3)'"$PS1" torch% ELAPSED: 3.015070000000037 seconds