15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_COMMON_PROFILING_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_COMMON_PROFILING_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "build/build_config.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/debug/profiler.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The Profiling class manages the interaction with a sampling based profiler. 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Its function is controlled by the kProfilingAtStart, kProfilingFile, and 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// kProfilingFlush command line values. 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// All of the API should only be called from the main thread of the process. 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Profiling { 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called early in a process' life to allow profiling of startup time. 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the presence of kProfilingAtStart is checked. 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void ProcessStarted(); 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Start profiling. 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void Start(); 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stop profiling and write out profiling file. 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void Stop(); 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if the process is being profiled. 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool BeingProfiled(); 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Toggle profiling on/off. 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void Toggle(); 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Do not instantiate this class. 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Profiling(); 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(Profiling); 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_COMMON_PROFILING_H_ 43