1*635a8641SAndroid Build Coastguard Worker // Copyright 2013 The Chromium Authors. All rights reserved. 2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file. 4*635a8641SAndroid Build Coastguard Worker 5*635a8641SAndroid Build Coastguard Worker #ifndef BASE_TEST_PERF_TIME_LOGGER_H_ 6*635a8641SAndroid Build Coastguard Worker #define BASE_TEST_PERF_TIME_LOGGER_H_ 7*635a8641SAndroid Build Coastguard Worker 8*635a8641SAndroid Build Coastguard Worker #include <string> 9*635a8641SAndroid Build Coastguard Worker 10*635a8641SAndroid Build Coastguard Worker #include "base/macros.h" 11*635a8641SAndroid Build Coastguard Worker #include "base/timer/elapsed_timer.h" 12*635a8641SAndroid Build Coastguard Worker 13*635a8641SAndroid Build Coastguard Worker namespace base { 14*635a8641SAndroid Build Coastguard Worker 15*635a8641SAndroid Build Coastguard Worker // Automates calling LogPerfResult for the common case where you want 16*635a8641SAndroid Build Coastguard Worker // to measure the time that something took. Call Done() when the test 17*635a8641SAndroid Build Coastguard Worker // is complete if you do extra work after the test or there are stack 18*635a8641SAndroid Build Coastguard Worker // objects with potentially expensive constructors. Otherwise, this 19*635a8641SAndroid Build Coastguard Worker // class with automatically log on destruction. 20*635a8641SAndroid Build Coastguard Worker class PerfTimeLogger { 21*635a8641SAndroid Build Coastguard Worker public: 22*635a8641SAndroid Build Coastguard Worker explicit PerfTimeLogger(const char* test_name); 23*635a8641SAndroid Build Coastguard Worker ~PerfTimeLogger(); 24*635a8641SAndroid Build Coastguard Worker 25*635a8641SAndroid Build Coastguard Worker void Done(); 26*635a8641SAndroid Build Coastguard Worker 27*635a8641SAndroid Build Coastguard Worker private: 28*635a8641SAndroid Build Coastguard Worker bool logged_; 29*635a8641SAndroid Build Coastguard Worker std::string test_name_; 30*635a8641SAndroid Build Coastguard Worker ElapsedTimer timer_; 31*635a8641SAndroid Build Coastguard Worker 32*635a8641SAndroid Build Coastguard Worker DISALLOW_COPY_AND_ASSIGN(PerfTimeLogger); 33*635a8641SAndroid Build Coastguard Worker }; 34*635a8641SAndroid Build Coastguard Worker 35*635a8641SAndroid Build Coastguard Worker } // namespace base 36*635a8641SAndroid Build Coastguard Worker 37*635a8641SAndroid Build Coastguard Worker #endif // BASE_TEST_PERF_TIME_LOGGER_H_ 38