1#
2#   Copyright (C) 2021-2023 Free Software Foundation, Inc.
3#
4# This file is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; see the file COPYING3.  If not see
16# <http://www.gnu.org/licenses/>.
17#
18#------------------------------------------------------------------------------
19# This script demonstrates how to use gprofng.
20#
21# After the experiment data has been generated, several views into the data
22# are shown.
23#------------------------------------------------------------------------------
24
25#------------------------------------------------------------------------------
26# Define the executable, algorithm parameters and gprofng settings.
27#------------------------------------------------------------------------------
28exe=../experiments/mxv-pthreads
29rows=4000
30columns=2000
31threads=2
32exp_directory=experiment.$threads.thr.er
33
34#------------------------------------------------------------------------------
35# Check if gprofng has been installed and can be executed.
36#------------------------------------------------------------------------------
37which gprofng > /dev/null 2>&1
38if (test $? -eq 0) then
39  echo  ""
40  echo "Version information of the gprofng release used:"
41  echo  ""
42  gprofng --version
43  echo  ""
44else
45  echo "Error: gprofng cannot be found - if it was installed, check your path"
46  exit
47fi
48
49#------------------------------------------------------------------------------
50# Check if the executable is present.
51#------------------------------------------------------------------------------
52if (! test -x $exe) then
53  echo "Error: executable $exe not found - check the make install command"
54  exit
55fi
56
57echo "-------------- Collect the experiment data -----------------------------"
58gprofng collect app -O $exp_directory $exe -m $rows -n $columns -t $threads
59
60#------------------------------------------------------------------------------
61# Make sure that the collect experiment succeeded and created an experiment
62# directory with the performance data.
63#------------------------------------------------------------------------------
64if (! test -d $exp_directory) then
65  echo "Error: experiment directory $exp_directory not found"
66  exit
67fi
68
69echo "-------------- Show the function overview  -----------------------------"
70gprofng display text -functions $exp_directory
71
72echo "-------------- Show the function overview limit to the top 5 -----------"
73gprofng display text -limit 5 -functions $exp_directory
74
75echo "-------------- Show the source listing of mxv_core ---------------------"
76gprofng display text -metrics e.totalcpu -source mxv_core $exp_directory
77
78echo "-------------- Show the disassembly listing of mxv_core ----------------"
79gprofng display text -metrics e.totalcpu -disasm mxv_core $exp_directory
80