00001 /**** 00002 ***** Copyright 2010 Intel Corporation All Rights Reserved. 00003 ***** 00004 ***** The source code, information and material contained herein are owned by Intel Corporation or its suppliers ***** 00005 ***** or licensors, and title to such Material remains with Intel Corporation or its suppliers or licensors. ***** 00006 ***** The Material contains proprietary information of Intel or its suppliers and licensors. The Material is ***** 00007 ***** protected by worldwide copyright laws and treaty provisions. No part of the Material may be used, copied, ***** 00008 ***** reproduced, modified, published, uploaded, posted, transmitted, distributed or disclosed in any way without ***** 00009 ***** Intel's prior express written permission. 00010 ***** 00011 ***** No license under any patent, copyright or other intellectual property rights in the material is granted to ***** 00012 ***** or conferred upon you, either expressly, by implication, inducement, estoppel or otherwise. Any license ***** 00013 ***** under such intellectual property rights must be express and approved by Intel in writing. 00014 ****/ 00015 00016 /**** Copyright Ends ****/ 00017 00018 #ifndef ARBB_CPP_SCOPED_TIMER_HPP 00019 #define ARBB_CPP_SCOPED_TIMER_HPP 00020 00021 #include "namespace.hpp" 00022 #include <memory> 00023 00024 namespace ARBB_CPP_NS { 00025 00034 template <typename source_t, 00035 typename stamp_t = typename source_t::stamp_type, 00036 typename value_t = typename source_t::value_type> 00037 class scoped_timer_impl: private source_t { 00038 public: 00039 typedef value_t value_type; 00040 typedef source_t source_type; 00041 typedef stamp_t stamp_type; 00042 00044 enum unit_type { 00046 unit_us, 00048 unit_ms, 00050 unit_s 00051 }; 00052 00055 template<typename time_value_t> 00056 explicit scoped_timer_impl( 00058 time_value_t& time_value, 00060 unit_type unit = unit_ms); 00061 00067 template<typename time_value_t> 00068 scoped_timer_impl( 00070 time_value_t& time_value, 00072 bool precondition, 00074 unit_type unit = unit_ms); 00075 00079 ~scoped_timer_impl(); 00080 00082 bool precondition() const; 00083 00085 unit_type unit() const; 00086 00088 stamp_type stamp() const; 00089 00090 private: 00091 scoped_timer_impl(const scoped_timer_impl&); 00092 scoped_timer_impl& operator=(const scoped_timer_impl&); 00093 00094 bool m_synchronization; 00095 unit_type m_unit; 00096 stamp_type m_stamp; 00097 00098 template<typename T> struct wrap; 00099 struct wrap_type; 00100 00101 std::auto_ptr<wrap_type> m_value; 00102 }; 00103 00104 00106 class system_time_source { 00107 public: 00108 typedef long long stamp_type; 00109 typedef double value_type; 00110 00112 static stamp_type get_time_stamp(); 00113 00116 static value_type get_time_value_us(stamp_type begin, stamp_type end); 00117 }; 00118 00120 typedef scoped_timer_impl<system_time_source> scoped_timer; 00121 00122 } // namespace ARBB_CPP_NS 00123 00124 #endif // ARBB_CPP_SCOPED_TIMER_HPP
Copyright © 2010, Intel Corporation. All rights reserved.