FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
Dobbs M-Dev
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
May 01, 2003

Win32 Performance Measurement Options

(Page 9 of 19)

Listing 7 Extract from winstl_performance_counter_scope.h


/* /////////////////////////////////////////////////////////////
 * ...
 *
 * Extract from winstl_performance_counter_scope.h
 *
 * Copyright (C) 2002, Synesis Software Pty Ltd.
 * (Licensed under the Synesis Software Standard Source License:
 *  http://www.synesis.com.au/licenses/ssssl.html)
 *
 * ...
 * ////////////////////////////////////////////////////////// */

// class performance_counter_scope
template <ws_typename_param_k T>
class performance_counter_scope
{
public:
    typedef T                               counter_type;
    typedef performance_counter_scope<T>    class_type;

public:
    ws_explicit_k performance_counter_scope(counter_type &counter)
        : m_counter(counter)
    {
        m_counter.start();
    }
    ~performance_counter_scope()
    {
        m_counter.stop();
    }

    void stop()
    {
        m_counter.stop();
    }

    // This method is const, to ensure that only the stop operation 
    // (via performance_counter_scope::stop()) is accessible 
    // on the managed counter.
    const counter_type &get_counter() const
    {
        return m_counter;
    }

// Members
protected:
    T   &m_counter;

// Not to be implemented
private:
    performance_counter_scope(class_type const &rhs);
    class_type const &operator =(class_type const &rhs);
};
Previous Page | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 Next Page
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK