Profiling CLI. Wip.

This commit is contained in:
Christian Speckner 2019-02-25 23:56:57 +01:00
parent 6709b43f9c
commit 58d7846f6b
4 changed files with 109 additions and 0 deletions

View File

@ -31,6 +31,7 @@
#include "PNGLibrary.hxx" #include "PNGLibrary.hxx"
#include "System.hxx" #include "System.hxx"
#include "TIASurface.hxx" #include "TIASurface.hxx"
#include "ProfilingRunner.hxx"
#include "ThreadDebugging.hxx" #include "ThreadDebugging.hxx"
@ -139,6 +140,13 @@ void checkForCustomBaseDir(Settings::Options& options)
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool isProfilingRun(int ac, char* av[]) {
if (ac <= 1) return false;
return string(av[1]) == "-profile";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#if defined(BSPF_MACOS) #if defined(BSPF_MACOS)
int stellaMain(int ac, char* av[]) int stellaMain(int ac, char* av[])
@ -150,6 +158,12 @@ int main(int ac, char* av[])
std::ios_base::sync_with_stdio(false); std::ios_base::sync_with_stdio(false);
if (isProfilingRun(ac, av)) {
ProfilingRunner runner(ac, av);
return runner.run() ? 0 : 1;
}
unique_ptr<OSystem> theOSystem; unique_ptr<OSystem> theOSystem;
auto Cleanup = [&theOSystem]() { auto Cleanup = [&theOSystem]() {

View File

@ -0,0 +1,52 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "ProfilingRunner.hxx"
static constexpr uInt32 RUNTIME_DEFAULT = 60;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ProfilingRunner::ProfilingRunner(int argc, char* argv[])
: profilingRuns(std::max(argc - 2, 0))
{
for (int i = 2; i < argc; i++) {
ProfilingRun& run(profilingRuns[i-2]);
string arg = argv[i];
size_t splitPoint = arg.find_first_of(":");
run.romFile = splitPoint == string::npos ? arg : arg.substr(0, splitPoint);
if (splitPoint == string::npos) run.runtime = RUNTIME_DEFAULT;
else {
int runtime = atoi(arg.substr(splitPoint+1, string::npos).c_str());
run.runtime = runtime > 0 ? runtime : RUNTIME_DEFAULT;
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ProfilingRunner::run()
{
cout << "Profiling Stela..." << endl << endl;
for (ProfilingRun& run : profilingRuns) {
cout << "running " << run.romFile << " for " << run.runtime << " seconds..." << endl;
}
return true;
}

View File

@ -0,0 +1,42 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifndef PROFILING_RUNNER
#define PROFILING_RUNNER
#include <bspf.hxx>
class ProfilingRunner {
public:
ProfilingRunner(int argc, char* argv[]);
bool run();
private:
struct ProfilingRun {
string romFile;
uInt32 runtime;
};
private:
vector<ProfilingRun> profilingRuns;
};
#endif // PROFILING_RUNNER

View File

@ -73,6 +73,7 @@ MODULE_OBJS := \
src/emucore/OSystem.o \ src/emucore/OSystem.o \
src/emucore/Paddles.o \ src/emucore/Paddles.o \
src/emucore/PointingDevice.o \ src/emucore/PointingDevice.o \
src/emucore/ProfilingRunner.o \
src/emucore/Props.o \ src/emucore/Props.o \
src/emucore/PropsSet.o \ src/emucore/PropsSet.o \
src/emucore/SaveKey.o \ src/emucore/SaveKey.o \