1# -*- cperl -*-
2# Copyright (c) 2004 MySQL AB, 2008 Sun Microsystems, Inc.
3# Use is subject to license terms.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License, version 2.0,
7# as published by the Free Software Foundation.
8#
9# This program is also distributed with certain software (including
10# but not limited to OpenSSL) that is licensed under separate terms,
11# as designated in a particular file or component or in included license
12# documentation.  The authors of MySQL hereby grant you an additional
13# permission to link the program and your derivative works with the
14# separately licensed software that they have included with MySQL.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19# GNU General Public License, version 2.0, for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with this program; if not, write to the Free Software
23# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24
25# This is a library file used by the Perl version of mysql-test-run,
26# and is part of the translation of the Bourne shell script with the
27# same name.
28
29use strict;
30
31# These are not to be prefixed with "mtr_"
32
33sub gprof_prepare ();
34sub gprof_collect ();
35
36##############################################################################
37#
38#
39#
40##############################################################################
41
42sub gprof_prepare () {
43
44  rmtree($::opt_gprof_dir);
45  mkdir($::opt_gprof_dir);
46}
47
48# FIXME what about master1 and slave1?!
49sub gprof_collect () {
50
51  if ( -f "$::master->[0]->{'path_myddir'}/gmon.out" )
52  {
53    # FIXME check result code?!
54    mtr_run("gprof",
55            [$::exe_master_mysqld,
56             "$::master->[0]->{'path_myddir'}/gmon.out"],
57            $::opt_gprof_master, "", "", "");
58    print "Master execution profile has been saved in $::opt_gprof_master\n";
59  }
60  if ( -f "$::slave->[0]->{'path_myddir'}/gmon.out" )
61  {
62    # FIXME check result code?!
63    mtr_run("gprof",
64            [$::exe_slave_mysqld,
65             "$::slave->[0]->{'path_myddir'}/gmon.out"],
66            $::opt_gprof_slave, "", "", "");
67    print "Slave execution profile has been saved in $::opt_gprof_slave\n";
68  }
69}
70
71
721;
73