Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2 KiB

  1. //========= Copyright (c) 2009, Valve Corporation, All rights reserved. ============//
  2. #include "tier0/platform.h"
  3. #include "tier1/miniprofiler_hash.h"
  4. #if ENABLE_HARDWARE_PROFILER
  5. #include "tier1/UtlStringMap.h"
  6. CUtlStringMap<CLinkedMiniProfiler*> g_mapMiniProfilers;
  7. DLL_IMPORT CLinkedMiniProfiler *g_pOtherMiniProfilers;
  8. CLinkedMiniProfiler *HashMiniProfiler( const char *pString )
  9. {
  10. UtlSymId_t nString = g_mapMiniProfilers.Find( pString );
  11. if( nString == g_mapMiniProfilers.InvalidIndex() )
  12. {
  13. nString = g_mapMiniProfilers.AddString( pString );
  14. // this profiler does not exist yet
  15. CLinkedMiniProfiler ** ppProfiler = &g_mapMiniProfilers[nString];
  16. *ppProfiler = new CLinkedMiniProfiler( g_mapMiniProfilers.String( nString ), &g_pOtherMiniProfilers );
  17. return *ppProfiler;
  18. }
  19. return g_mapMiniProfilers[nString];
  20. }
  21. CLinkedMiniProfiler *HashMiniProfilerF( const char *pFormat, ... )
  22. {
  23. va_list args;
  24. va_start( args, pFormat );
  25. char buffer[2048];
  26. Q_vsnprintf( buffer, sizeof( buffer ), pFormat, args );
  27. CLinkedMiniProfiler *pProfiler = HashMiniProfiler( buffer );
  28. va_end( args ) ;
  29. return pProfiler;
  30. }
  31. #else
  32. CMiniProfiler *HashMiniProfiler( const char *pString )
  33. {
  34. return NULL;
  35. }
  36. #endif