Click here to Skip to main content
15,886,578 members
Articles / Web Development / HTML

Introducing Investigo: Using a Proxy DLL and embedded HTTP server for DirectX9 Performance Analysis, Debugging and Automated Performance Testing.

Rate me:
Please Sign up or sign in to vote.
4.90/5 (6 votes)
9 Nov 2012MIT48 min read 56.9K   1.4K   9  
Introducing Investigo: Using a Proxy DLL and embedded HTTP server for DirectX9 Performance Analysis, Debugging and Automated Performance Testing
//  boost/chrono/process_times.hpp  -----------------------------------------------------------//

//  Copyright Beman Dawes 1994, 2007, 2008
//  Copyright Vicente J Botet Escriba 2009-2010

//  Distributed under the Boost Software License, Version 1.0.
//  See http://www.boost.org/LICENSE_1_0.txt

//  See http://www.boost.org/libs/system for documentation.

#ifndef BOOST_PROCESS_TIMES_HPP
#define BOOST_PROCESS_TIMES_HPP

#include <boost/chrono/duration.hpp>
#include <boost/chrono/time_point.hpp>
#include <boost/system/error_code.hpp>
#include <boost/cstdint.hpp>
#include <string>
#include <ostream>
#include <boost/chrono/detail/system.hpp>

#ifndef BOOST_CHRONO_HEADER_ONLY
#include <boost/config/abi_prefix.hpp> // must be the last #include
#endif


namespace boost
{
namespace chrono
{
//--------------------------------------------------------------------------------------//
//                                  process_clock                                       //
//--------------------------------------------------------------------------------------//

    class BOOST_CHRONO_DECL process_clock
    {
    public:
        typedef nanoseconds                          duration;
        typedef duration::rep                        rep;
        typedef duration::period                     period;
        typedef chrono::time_point<process_clock>    time_point;
        BOOST_CHRONO_STATIC_CONSTEXPR bool is_steady =             true;

        struct durations
        {
          process_clock::duration                       real;    // real (i.e wall clock) time
          process_clock::duration                       user;    // user cpu time
          process_clock::duration                       system;  // system cpu time
        };
        struct time_points
        {
          process_clock::time_point                       real;    // real (i.e wall clock) time
          process_clock::time_point                       user;    // user cpu time
          process_clock::time_point                       system;  // system cpu time
        };

        static BOOST_CHRONO_INLINE void now( durations & times,
                         system::error_code & ec = BOOST_CHRONO_THROWS );
        static BOOST_CHRONO_INLINE void now( time_points & times,
                         system::error_code & ec = BOOST_CHRONO_THROWS );
    };


//--------------------------------------------------------------------------------------//
//                                  process_times                                       //
//--------------------------------------------------------------------------------------//

    typedef process_clock::durations process_times;

//--------------------------------------------------------------------------------------//
//                                  process_timer                                       //
//--------------------------------------------------------------------------------------//

    class BOOST_CHRONO_DECL process_timer
    // BOOST_CHRONO_DECL is required to quiet compiler warnings even though
    // process_timer has no dynamically linked members, because process_timer is
    // used as a base class for run_timer, which does have dynamically linked members.
    {
    public:

      typedef process_clock                          clock;
      typedef process_clock::duration                duration;
      typedef process_clock::time_point              time_point;

      explicit process_timer( system::error_code & ec = BOOST_CHRONO_THROWS )
      {
        start(ec);
      }

     ~process_timer() {}  // never throws()

      void  start( system::error_code & ec = BOOST_CHRONO_THROWS )
      {
        process_clock::now( m_start, ec );
      }

      void  elapsed( process_times & times, system::error_code & ec = BOOST_CHRONO_THROWS )
      {
        process_times end;
        process_clock::now( end, ec );
        times.real  = end.real - m_start.real;
        times.user       = end.user - m_start.user;
        times.system     = end.system - m_start.system;
      }

    protected:
      process_times   m_start;
    private:
      process_timer(const process_timer&); // = delete;
      process_timer& operator=(const process_timer&); // = delete;
    };

//--------------------------------------------------------------------------------------//
//                                    run_timer                                         //
//--------------------------------------------------------------------------------------//

    class BOOST_CHRONO_DECL run_timer : public process_timer
    {
      // every function making use of inlined functions of class string are not inlined to avoid DLL issues
    public:

      // each constructor form has two overloads to avoid a visible default to
      // std::cout, which in turn would require including <iostream>, with its
      // high associated cost, even when the standard streams are not used.

      BOOST_CHRONO_INLINE
      explicit run_timer( system::error_code & ec = BOOST_CHRONO_THROWS );
      BOOST_CHRONO_INLINE
      explicit run_timer( std::ostream & os,
        system::error_code & ec = BOOST_CHRONO_THROWS );

      BOOST_CHRONO_INLINE
      explicit run_timer( const std::string & format,
        system::error_code & ec = BOOST_CHRONO_THROWS );
      BOOST_CHRONO_INLINE
      run_timer( std::ostream & os, const std::string & format,
        system::error_code & ec = BOOST_CHRONO_THROWS );

      BOOST_CHRONO_INLINE
      run_timer( const std::string & format, int places,
        system::error_code & ec = BOOST_CHRONO_THROWS );
      BOOST_CHRONO_INLINE
      run_timer( std::ostream & os, const std::string & format,
        int places, system::error_code & ec = BOOST_CHRONO_THROWS );

      BOOST_CHRONO_INLINE
      explicit run_timer( int places,
        system::error_code & ec = BOOST_CHRONO_THROWS );
      BOOST_CHRONO_INLINE
      run_timer( std::ostream & os, int places,
        system::error_code & ec = BOOST_CHRONO_THROWS );

      BOOST_CHRONO_INLINE
      run_timer( int places, const std::string & format,
        system::error_code & ec = BOOST_CHRONO_THROWS );
      BOOST_CHRONO_INLINE
      run_timer( std::ostream & os, int places, const std::string & format,
        system::error_code & ec = BOOST_CHRONO_THROWS );

      ~run_timer()  // never throws
      {
        system::error_code ec;
        if ( !reported() ) report( ec );
      }

      BOOST_CHRONO_INLINE void  start( system::error_code & ec = BOOST_CHRONO_THROWS )
      {
        m_reported = false;
        process_timer::start( ec );
      }

      BOOST_CHRONO_INLINE void  report( system::error_code & ec = BOOST_CHRONO_THROWS );

      BOOST_CHRONO_INLINE void  test_report( duration real_, duration user_, duration system_ );

      BOOST_CHRONO_INLINE bool  reported() const { return m_reported; }

      BOOST_CHRONO_INLINE static int default_places() { return m_default_places; }

    private:
      int             m_places;
      std::ostream &  m_os;

#if defined _MSC_VER
#pragma warning(push)
#pragma warning(disable:4251)
#endif
      std::string     m_format;
#if defined _MSC_VER
#pragma warning(pop)
#endif
      bool            m_reported;

      BOOST_CHRONO_INLINE static std::ostream &  m_cout();
      //{return std::cout;}
      static const int m_default_places = 3;
      run_timer(const run_timer&); // = delete;
      run_timer& operator=(const run_timer&); // = delete;
    };

  } // namespace chrono
} // namespace boost

#ifndef BOOST_CHRONO_HEADER_ONLY
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
#else
#include <boost/chrono/detail/inlined/process_clock.hpp>
#include <boost/chrono/detail/inlined/run_timer.hpp>
#include <boost/chrono/detail/inlined/run_timer_static.hpp>
#endif

#endif  // BOOST_PROCESS_TIMES_HPP

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Chief Technology Officer
Australia Australia
Software craftsman | Author | Writing rapidfullstackdevelopment.com - Posting about how to survive and flourish as a software developer

Follow on Twitter for news and updates: https://twitter.com/codecapers

I'm writing a new book: Rapid Fullstack Development. Learn from my years of experience and become a better developer.

My second book, Bootstrapping Microservices, is a practical and project-based guide to building distributed applications with microservices.

My first book Data Wrangling with JavaScript is a comprehensive overview of working with data in JavaScript.

Data-Forge Notebook is my notebook-style application for data transformation, analysis and transformation in JavaScript.

I have a long history in software development with many years in apps, web apps, backends, serious games, simulations and VR. Making technology work for business is what I do: building bespoke software solutions that span multiple platforms.

I have years of experience managing development teams, preparing technical strategies and creation of software products. I can explain complicated technology to senior management. I have delivered cutting-edge products in fast-paced and high-pressure environments. I know how to focus and prioritize to get the important things done.

Author

- Rapid Fullstack Development
- Bootstrapping Microservices
- Data Wrangling with JavaScript

Creator of Market Wizard

- https://www.market-wizard.com.au/

Creator of Data-Forge and Data-Forge Notebook

- http://www.data-forge-js.com
- http://www.data-forge-notebook.com

Web

- www.codecapers.com.au

Open source

- https://github.com/ashleydavis
- https://github.com/data-forge
- https://github.com/data-forge-notebook


Skills

- Quickly building MVPs for startups
- Understanding how to get the most out of technology for business
- Developing technical strategies
- Management and coaching of teams & projects
- Microservices, devops, mobile and fullstack software development

Comments and Discussions