From owner-freebsd-questions@freebsd.org Sat Nov 28 19:22:34 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 88C9A4688B9 for ; Sat, 28 Nov 2020 19:22:34 +0000 (UTC) (envelope-from bennett@sdf.org) Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mx.sdf.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ck1bY4lNjz4ft2 for ; Sat, 28 Nov 2020 19:22:33 +0000 (UTC) (envelope-from bennett@sdf.org) Received: from sdf.org (IDENT:bennett@faeroes.freeshell.org [205.166.94.9]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 0ASJML3C019479 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Sat, 28 Nov 2020 19:22:21 GMT Received: (from bennett@localhost) by sdf.org (8.15.2/8.12.8/Submit) id 0ASJMtiH020409; Sat, 28 Nov 2020 13:22:55 -0600 (CST) From: Scott Bennett Message-Id: <202011281922.0ASJMtiH020409@sdf.org> Date: Sat, 28 Nov 2020 13:22:55 -0600 To: ihor@antonovs.family Subject: Re: Profiling C application Cc: freebsd-questions@freebsd.org User-Agent: Heirloom mailx 12.5 6/20/10 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4Ck1bY4lNjz4ft2 X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.80 / 15.00]; FAKE_REPLY(1.00)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[205.166.94.24:from]; R_SPF_ALLOW(-0.20)[+ip4:205.166.94.0/24]; MID_RHS_MATCH_FROM(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; SPAMHAUS_ZRD(0.00)[205.166.94.24:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-0.997]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[sdf.org,quarantine]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:14361, ipnet:205.166.94.0/24, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[freebsd-questions] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Nov 2020 19:22:34 -0000 On Fri, 27 Nov 2020 19:38:28 -0800 Ihor Antonov wrote: >What can I use on FreeBSD to profile a slow application? > >I have a source code of the application and I can rebuild it if necessary. > >I want to see where (in what functions) application spends most of its >time - amount of function calls and duration of each call (per call) > >What tools can you recommend to do this? > I see you already have one response at least to your question, but perhaps a simpler one is to use a now ancient BSD UNIX tool called gprof(1), along with the compiler option -pg. (See the gprof(1) man page for the details.) Note, too, that you may want to link your program to the profiling versions of system libraries as explained in the man page. Scott Bennett, Comm. ASMELG, CFIAG ********************************************************************** * Internet: bennett at sdf.org *xor* bennett at freeshell.org * *--------------------------------------------------------------------* * "A well regulated and disciplined militia, is at all times a good * * objection to the introduction of that bane of all free governments * * -- a standing army." * * -- Gov. John Hancock, New York Journal, 28 January 1790 * **********************************************************************