VTuneProfiler.cpp (2787B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifdef XP_WIN 8 # undef UNICODE 9 # undef _UNICODE 10 #endif 11 12 #include "VTuneProfiler.h" 13 14 #include "mozilla/BaseProfiler.h" 15 16 namespace mozilla { 17 namespace baseprofiler { 18 19 VTuneProfiler* VTuneProfiler::mInstance = nullptr; 20 21 void VTuneProfiler::Initialize() { 22 // This is just a 'dirty trick' to find out if the ittnotify DLL was found. 23 // If it wasn't this function always returns 0, otherwise it returns 24 // incrementing numbers, if the library was found this wastes 2 events but 25 // that should be okay. 26 // TODO re-implement here if vtune is needed 27 // __itt_event testEvent = 28 // __itt_event_create("Test event", strlen("Test event")); 29 // testEvent = __itt_event_create("Test event 2", strlen("Test event 2")); 30 31 // if (testEvent) { 32 // mInstance = new VTuneProfiler(); 33 // } 34 } 35 36 void VTuneProfiler::Shutdown() {} 37 38 void VTuneProfiler::TraceInternal(const char* aName, TracingKind aKind) { 39 // TODO re-implement here if vtune is needed 40 // std::string str(aName); 41 42 // auto iter = mStrings.find(str); 43 44 // __itt_event event; 45 // if (iter != mStrings.end()) { 46 // event = iter->second; 47 // } else { 48 // event = __itt_event_create(aName, str.length()); 49 // mStrings.insert({str, event}); 50 // } 51 52 // if (aKind == TRACING_INTERVAL_START || aKind == TRACING_EVENT) { 53 // // VTune will consider starts not matched with an end to be single point 54 // in 55 // // time events. 56 // __itt_event_start(event); 57 // } else { 58 // __itt_event_end(event); 59 // } 60 } 61 62 void VTuneProfiler::RegisterThreadInternal(const char* aName) { 63 // TODO re-implement here if vtune is needed 64 // std::string str(aName); 65 66 // if (!str.compare("Main Thread (Base Profiler)")) { 67 // // Process main thread. 68 // switch (XRE_GetProcessType()) { 69 // case GeckoProcessType::GeckoProcessType_Default: 70 // __itt_thread_set_name("Main Process"); 71 // break; 72 // case GeckoProcessType::GeckoProcessType_Content: 73 // __itt_thread_set_name("Content Process"); 74 // break; 75 // case GeckoProcessType::GeckoProcessType_GMPlugin: 76 // __itt_thread_set_name("Plugin Process"); 77 // break; 78 // case GeckoProcessType::GeckoProcessType_GPU: 79 // __itt_thread_set_name("GPU Process"); 80 // break; 81 // default: 82 // __itt_thread_set_name("Unknown Process"); 83 // } 84 // return; 85 // } 86 // __itt_thread_set_name(aName); 87 } 88 89 } // namespace baseprofiler 90 } // namespace mozilla