2017-06-04 20:38:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <map>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <functional>
|
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
#include "EventArgs.h"
|
|
|
|
#include "Signal.h"
|
2017-06-04 20:38:34 +00:00
|
|
|
|
|
|
|
#include "Disassembly.h"
|
|
|
|
#include "Symbols.h"
|
|
|
|
|
|
|
|
#include "ProfileLineEventArgs.h"
|
|
|
|
#include "ProfileScopeEventArgs.h"
|
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
#include "mos6502.h"
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
namespace EightBit {
|
|
|
|
class Profiler {
|
|
|
|
public:
|
|
|
|
std::array<uint64_t, 0x100> instructionCounts;
|
|
|
|
std::array<uint64_t, 0x10000> addressProfiles;
|
|
|
|
std::array<uint64_t, 0x10000> addressCounts;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
std::array<std::string, 0x10000> addressScopes;
|
|
|
|
std::map<std::string, uint64_t> scopeCycles;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
MOS6502& processor;
|
|
|
|
const Disassembly& disassembler;
|
|
|
|
const Symbols& symbols;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
Profiler(MOS6502& processor, Disassembly& disassembler, Symbols& symbols);
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
Signal<EventArgs> StartingOutput;
|
|
|
|
Signal<EventArgs> FinishedOutput;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
Signal<EventArgs> StartingLineOutput;
|
|
|
|
Signal<EventArgs> FinishedLineOutput;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
Signal<ProfileLineEventArgs> EmitLine;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
Signal<EventArgs> StartingScopeOutput;
|
|
|
|
Signal<EventArgs> FinishedScopeOutput;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
Signal<ProfileScopeEventArgs> EmitScope;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
void addInstruction(uint8_t instruction);
|
|
|
|
void addAddress(uint16_t address, int cycles);
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
void Generate();
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
private:
|
|
|
|
void EmitProfileInformation();
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
void BuildAddressScopes();
|
|
|
|
};
|
|
|
|
}
|