diff options
author | Colin Patrick McCabe <cmccabe@alumni.cmu.edu> | 2011-02-28 16:42:28 +0100 |
---|---|---|
committer | Colin Patrick McCabe <cmccabe@alumni.cmu.edu> | 2011-03-01 15:45:09 +0100 |
commit | 7a429d9194b29075fdb487c02ca3fd1d1bde57b1 (patch) | |
tree | 832a70396eb20f30429c3fa63f5a0ead44181283 /src/perfglue | |
parent | do_autogen: add -P (--with-profiler) (diff) | |
download | ceph-7a429d9194b29075fdb487c02ca3fd1d1bde57b1.tar.xz ceph-7a429d9194b29075fdb487c02ca3fd1d1bde57b1.zip |
profiler: move perftools glue into perfglue/
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
Diffstat (limited to 'src/perfglue')
-rw-r--r-- | src/perfglue/cpu_profiler.cc | 60 | ||||
-rw-r--r-- | src/perfglue/cpu_profiler.h | 27 | ||||
-rw-r--r-- | src/perfglue/disabled_stubs.cc | 25 |
3 files changed, 112 insertions, 0 deletions
diff --git a/src/perfglue/cpu_profiler.cc b/src/perfglue/cpu_profiler.cc new file mode 100644 index 00000000000..856b96b2f9d --- /dev/null +++ b/src/perfglue/cpu_profiler.cc @@ -0,0 +1,60 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2011 New Dream Network + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#include "common/LogClient.h" +#include "perfglue/cpu_profiler.h" + +#include <google/profiler.h> + +void cpu_profiler_handle_command(const std::vector<std::string> &cmd, + LogClient &clog) +{ + if (cmd[1] == "start") { + if (cmd.size() < 3) { + clog.info() << "cpu_profiler: you must give an argument to start: a " + << "file name to log to.\n"; + return; + } + const char *file = cmd[2].c_str(); + int r = ProfilerStart(file); + clog.info() << "cpu_profiler: starting logging to " << file + << ", r=" << r << "\n"; + } + else if (cmd[1] == "status") { + if (ProfilingIsEnabledForAllThreads()) + clog.info() << "cpu_profiler is enabled\n"; + else + clog.info() << "cpu_profiler is not enabled\n"; + ProfilerState st; + ProfilerGetCurrentState(&st); + clog.info() << "cpu_profiler " << (st.enabled ? "enabled":"not enabled") + << " start_time " << st.start_time + << " profile_name " << st.profile_name + << " samples " << st.samples_gathered + << "\n"; + } + else if (cmd[1] == "flush") { + clog.info() << "cpu_profiler: flushing\n"; + ProfilerFlush(); + } + else if (cmd[1] == "stop") { + clog.info() << "cpu_profiler: flushing and stopping\n"; + ProfilerFlush(); + ProfilerStop(); + } + else { + clog.info() << "can't understand cpu_profiler command. Expected one of: " + << "start,status,flush,stop.\n"; + } +} diff --git a/src/perfglue/cpu_profiler.h b/src/perfglue/cpu_profiler.h new file mode 100644 index 00000000000..a5b6a97ec58 --- /dev/null +++ b/src/perfglue/cpu_profiler.h @@ -0,0 +1,27 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2011 New Dream Network + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ +#ifndef CEPH_PERFGLUE_CPU_PROFILER + +/* + * Ceph glue for the Google Perftools CPU profiler + */ +#include <string> +#include <vector> + +class LogClient; + +void cpu_profiler_handle_command(const std::vector<std::string> &cmd, + LogClient &clog); + +#endif diff --git a/src/perfglue/disabled_stubs.cc b/src/perfglue/disabled_stubs.cc new file mode 100644 index 00000000000..ad5b23bcfa3 --- /dev/null +++ b/src/perfglue/disabled_stubs.cc @@ -0,0 +1,25 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2011 New Dream Network + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#include "common/LogClient.h" +#include "perfglue/cpu_profiler.h" + +#include <vector> +#include <string> + +void cpu_profiler_handle_command(const std::vector<std::string> &cmd, + LogClient &clog) +{ + clog.info() << "cpu_profiler support not linked in\n"; +} |