Advertisement
historic_bruno

gc profiling

Jan 31st, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.90 KB | None | 0 0
  1. Index: source/graphics/MapGenerator.cpp
  2. ===================================================================
  3. --- source/graphics/MapGenerator.cpp    (revision 13133)
  4. +++ source/graphics/MapGenerator.cpp    (working copy)
  5. @@ -64,6 +64,8 @@
  6.  {
  7.     debug_SetThreadName("MapGenerator");
  8.  
  9. +   g_Profiler2.RegisterCurrentThread("mapgenerator");
  10. +
  11.     CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(data);
  12.  
  13.     self->m_ScriptInterface = new ScriptInterface("RMS", "MapGenerator", ScriptInterface::CreateRuntime(RMS_RUNTIME_SIZE));
  14. Index: source/scriptinterface/ScriptInterface.cpp
  15. ===================================================================
  16. --- source/scriptinterface/ScriptInterface.cpp  (revision 13133)
  17. +++ source/scriptinterface/ScriptInterface.cpp  (working copy)
  18. @@ -436,6 +436,34 @@
  19.     return JS_TRUE;
  20.  }
  21.  
  22. +JSBool GCCallback(JSContext* UNUSED(cx), JSGCStatus status)
  23. +{
  24. +   switch(status)
  25. +   {
  26. +   case JSGC_BEGIN:
  27. +       if (CProfileManager::IsInitialised() && ThreadUtil::IsMainThread())
  28. +           g_Profiler.Start("JS GC");
  29. +
  30. +       g_Profiler2.RecordRegionEnter("JS GC");
  31. +       break;
  32. +   case JSGC_MARK_END:
  33. +       g_Profiler2.RecordEvent("JS GC mark end");
  34. +       break;
  35. +   case JSGC_FINALIZE_END:
  36. +       g_Profiler2.RecordEvent("JS GC finalize end");
  37. +       break;
  38. +   case JSGC_END:
  39. +       if (CProfileManager::IsInitialised() && ThreadUtil::IsMainThread())
  40. +           g_Profiler.Stop();
  41. +
  42. +       g_Profiler2.RecordRegionLeave("JS GC");
  43. +       break;
  44. +   default:
  45. +       debug_warn(L"Invalid status in GCCallback");
  46. +   }
  47. +   return JS_TRUE;
  48. +}
  49. +
  50.  // Math override functions:
  51.  
  52.  // boost::uniform_real is apparently buggy in Boost pre-1.47 - for integer generators
  53. @@ -488,6 +516,8 @@
  54.  
  55.     JS_SetErrorReporter(m_cx, ErrorReporter);
  56.  
  57. +   JS_SetGCCallback(m_cx, GCCallback);
  58. +
  59.     uint32 options = 0;
  60.     options |= JSOPTION_STRICT; // "warn on dubious practice"
  61.     options |= JSOPTION_XML; // "ECMAScript for XML support: parse <!-- --> as a token"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement