64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#ifndef _OPTIMISATION_PROFILING_H_
|
|
#define _OPTIMISATION_PROFILING_H_
|
|
|
|
#ifndef ENABLE_PROFILE_MARKERS
|
|
#define ENABLE_PROFILE_MARKERS 0
|
|
#endif
|
|
|
|
#if (defined(_DURANGO) || defined (_GAMING_XBOX_SCARLETT)) && !defined(ITF_FINAL) && ENABLE_PROFILE_MARKERS
|
|
# define USE_PIX
|
|
# include <windows.h>
|
|
# include <pix.h>
|
|
# define PRF_Begin(NAME, ...) PIXBeginNamedEvent(0, NAME, __VA_ARGS__)
|
|
# define PRF_End() PIXEndNamedEvent()
|
|
#elif defined(_XBOX_VER) && !defined(ITF_FINAL) && ENABLE_PROFILE_MARKERS
|
|
# define USE_PIX
|
|
# include <xtl.h>
|
|
# include <pix.h>
|
|
# define PRF_Begin(NAME, ...) PIXBeginNamedEvent(0, NAME, __VA_ARGS__)
|
|
# define PRF_End() PIXEndNamedEvent()
|
|
#elif defined(CAFE) && !defined(ITF_FINAL) && ENABLE_PROFILE_MARKERS
|
|
#include <cafe/profiler/profiler_cpp.h>
|
|
# define PRF_Begin(NAME) {static const char* __profileName__ = NAME; PROFILERCodeBlockEnter(NAME)
|
|
# define PRF_End() PROFILERCodeBlockExit(__profileName__)}
|
|
#else
|
|
# define PRF_Begin(NAME, ...) (void)0
|
|
# define PRF_End() (void)0
|
|
#endif
|
|
|
|
#if defined(__cplusplus) && !defined(ITF_FINAL) && ENABLE_PROFILE_MARKERS
|
|
# include <stdarg.h>
|
|
# include <stdio.h>
|
|
# define PRF_Scoped(FMT, ...) PRF_ScopedC prf_##__LINE__(FMT, __VA_ARGS__)
|
|
class PRF_ScopedC
|
|
{
|
|
public:
|
|
PRF_ScopedC(const char* format, ...)
|
|
{
|
|
char tempstr[256];
|
|
va_list ap;
|
|
va_start(ap, format);
|
|
vsnprintf(tempstr, 256, format, ap);
|
|
va_end(ap);
|
|
|
|
PRF_Begin(tempstr);
|
|
}
|
|
~PRF_ScopedC() {PRF_End();}
|
|
};
|
|
#else
|
|
# define PRF_Scoped(FMT, ...) (void)0
|
|
#endif
|
|
|
|
#endif // _OPTIMISATION_PROFILING_H_
|