mirror of https://github.com/stella-emu/stella.git
Profiling CLI. Wip.
This commit is contained in:
parent
6709b43f9c
commit
58d7846f6b
|
@ -31,6 +31,7 @@
|
|||
#include "PNGLibrary.hxx"
|
||||
#include "System.hxx"
|
||||
#include "TIASurface.hxx"
|
||||
#include "ProfilingRunner.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)
|
||||
int stellaMain(int ac, char* av[])
|
||||
|
@ -150,6 +158,12 @@ int main(int ac, char* av[])
|
|||
|
||||
std::ios_base::sync_with_stdio(false);
|
||||
|
||||
if (isProfilingRun(ac, av)) {
|
||||
ProfilingRunner runner(ac, av);
|
||||
|
||||
return runner.run() ? 0 : 1;
|
||||
}
|
||||
|
||||
unique_ptr<OSystem> theOSystem;
|
||||
|
||||
auto Cleanup = [&theOSystem]() {
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -73,6 +73,7 @@ MODULE_OBJS := \
|
|||
src/emucore/OSystem.o \
|
||||
src/emucore/Paddles.o \
|
||||
src/emucore/PointingDevice.o \
|
||||
src/emucore/ProfilingRunner.o \
|
||||
src/emucore/Props.o \
|
||||
src/emucore/PropsSet.o \
|
||||
src/emucore/SaveKey.o \
|
||||
|
|
Loading…
Reference in New Issue