1 // Copyright 2008 Dolphin Emulator Project
2 // Licensed under GPLv2+
3 // Refer to the license.txt file included.
4 
5 #include "Core/HW/DSPLLE/DSPLLEGlobals.h"
6 
7 #include <cinttypes>
8 
9 #include "Common/CommonTypes.h"
10 #include "Common/File.h"
11 
12 #include "Core/DSP/DSPCore.h"
13 
14 namespace DSP
15 {
16 #if PROFILE
17 
18 #define PROFILE_MAP_SIZE 0x10000
19 
20 u64 g_profileMap[PROFILE_MAP_SIZE];
21 bool g_profile = false;
22 
ProfilerStart()23 void ProfilerStart()
24 {
25   g_profile = true;
26 }
27 
ProfilerAddDelta(int _addr,int _delta)28 void ProfilerAddDelta(int _addr, int _delta)
29 {
30   if (g_profile)
31   {
32     g_profileMap[_addr] += _delta;
33   }
34 }
35 
ProfilerInit()36 void ProfilerInit()
37 {
38   memset(g_profileMap, 0, sizeof(g_profileMap));
39 }
40 
ProfilerDump(u64 count)41 void ProfilerDump(u64 count)
42 {
43   File::IOFile pFile("DSP_Prof.txt", "wt");
44   if (pFile)
45   {
46     fprintf(pFile.GetHandle(), "Number of DSP steps: %" PRIu64 "\n\n", count);
47     for (int i = 0; i < PROFILE_MAP_SIZE; i++)
48     {
49       if (g_profileMap[i] > 0)
50       {
51         fprintf(pFile.GetHandle(), "0x%04X: %" PRIu64 "\n", i, g_profileMap[i]);
52       }
53     }
54   }
55 }
56 
57 #elif defined(_MSC_VER)
58 
59 namespace
60 {
61 char SilenceLNK4221;
62 };
63 
64 #endif
65 }  // namespace DSP
66