#At file:///home/bm136801/my/gprof-51/ based on revid:bjorn.munch@stripped
2870 Bjorn Munch 2010-01-05
Bug #49345 re-introduce gprof to mysql-test-run.pl
Was available in v1
Porting to v2 required some rewriting
Updated after review comments
modified:
mysql-test/lib/mtr_gprof.pl
mysql-test/mysql-test-run.pl
=== modified file 'mysql-test/lib/mtr_gprof.pl'
--- a/mysql-test/lib/mtr_gprof.pl 2006-12-31 00:02:27 +0000
+++ b/mysql-test/lib/mtr_gprof.pl 2010-01-05 20:35:50 +0000
@@ -20,43 +20,20 @@
use strict;
-# These are not to be prefixed with "mtr_"
+sub gprof_collect ($@) {
+ my ($exe_mysqld, @gprof_dirs)= @_;
-sub gprof_prepare ();
-sub gprof_collect ();
+ print ("Collecting gprof reports.....\n");
-##############################################################################
-#
-#
-#
-##############################################################################
-
-sub gprof_prepare () {
-
- rmtree($::opt_gprof_dir);
- mkdir($::opt_gprof_dir);
-}
-
-# FIXME what about master1 and slave1?!
-sub gprof_collect () {
-
- if ( -f "$::master->[0]->{'path_myddir'}/gmon.out" )
- {
- # FIXME check result code?!
- mtr_run("gprof",
- [$::exe_master_mysqld,
- "$::master->[0]->{'path_myddir'}/gmon.out"],
- $::opt_gprof_master, "", "", "");
- print "Master execution profile has been saved in $::opt_gprof_master\n";
- }
- if ( -f "$::slave->[0]->{'path_myddir'}/gmon.out" )
+ foreach my $datadir (@gprof_dirs)
{
- # FIXME check result code?!
- mtr_run("gprof",
- [$::exe_slave_mysqld,
- "$::slave->[0]->{'path_myddir'}/gmon.out"],
- $::opt_gprof_slave, "", "", "");
- print "Slave execution profile has been saved in $::opt_gprof_slave\n";
+ my $gprof_msg= "$datadir/gprof.msg";
+ my $gprof_err= "$datadir/gprof.err";
+ if ( -f "$datadir/gmon.out" )
+ {
+ system("gprof $exe_mysqld $datadir/gmon.out 2>$gprof_err >$gprof_msg");
+ print ("GPROF output in $gprof_msg, errors in $gprof_err\n");
+ }
}
}
=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl 2010-01-05 12:31:38 +0000
+++ b/mysql-test/mysql-test-run.pl 2010-01-05 20:35:50 +0000
@@ -87,6 +87,7 @@ use IO::Select;
require "lib/mtr_process.pl";
require "lib/mtr_io.pl";
require "lib/mtr_gcov.pl";
+require "lib/mtr_gprof.pl";
require "lib/mtr_misc.pl";
$SIG{INT}= sub { mtr_error("Got ^C signal"); };
@@ -167,6 +168,9 @@ our $opt_gcov_exe= "gcov";
our $opt_gcov_err= "mysql-test-gcov.msg";
our $opt_gcov_msg= "mysql-test-gcov.err";
+our $opt_gprof;
+our %gprof_dirs;
+
our $glob_debugger= 0;
our $opt_gdb;
our $opt_client_gdb;
@@ -745,6 +749,9 @@ sub run_worker ($) {
if ($opt_valgrind_mysqld) {
valgrind_exit_reports();
}
+ if ( $opt_gprof ) {
+ gprof_collect (find_mysqld($basedir), keys %gprof_dirs);
+ }
exit(0);
}
else {
@@ -858,6 +865,7 @@ sub command_line_setup {
# Coverage, profiling etc
'gcov' => \$opt_gcov,
+ 'gprof' => \$opt_gprof,
'valgrind|valgrind-all' => \$opt_valgrind,
'valgrind-mysqltest' => \$opt_valgrind_mysqltest,
'valgrind-mysqld' => \$opt_valgrind_mysqld,
@@ -1250,7 +1258,7 @@ sub command_line_setup {
# --------------------------------------------------------------------------
# Gcov flag
# --------------------------------------------------------------------------
- if ( $opt_gcov and ! $source_dist )
+ if ( ($opt_gcov or $opt_gprof) and ! $source_dist )
{
mtr_error("Coverage test needs the source - please use source dist");
}
@@ -4304,6 +4312,8 @@ sub mysqld_start ($$) {
}
# Remember this log file for valgrind error report search
$mysqld_logs{$output}= 1 if $opt_valgrind;
+ # Remember data dir for gmon.out files if using gprof
+ $gprof_dirs{$mysqld->value('datadir')}= 1 if $opt_gprof;
if ( defined $exe )
{
Attachment: [text/bzr-bundle] bzr/bjorn.munch@sun.com-20100105203550-w3nbhj4b9yfdq5n6.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-mtr branch (Bjorn.Munch:2870) Bug#49345 | Bjorn Munch | 5 Jan |