benchmark
This commit is contained in:
parent
81473da7fe
commit
2178bb4aca
1 changed files with 25 additions and 1 deletions
26
main.cpp
26
main.cpp
|
@ -371,10 +371,12 @@ int main(int argc, char *argv[])
|
|||
|
||||
std::string deserialize;
|
||||
|
||||
bool benchmark = false;
|
||||
|
||||
std::optional<std::string> dc11_device;
|
||||
|
||||
int opt = -1;
|
||||
while((opt = getopt(argc, argv, "hD:MT:Br:R:p:ndtL:bl:s:Q:N:J:XS:P1:")) != -1)
|
||||
while((opt = getopt(argc, argv, "hqD:MT:Br:R:p:ndtL:bl:s:Q:N:J:XS:P1:")) != -1)
|
||||
{
|
||||
switch(opt) {
|
||||
case 'h':
|
||||
|
@ -405,6 +407,10 @@ int main(int argc, char *argv[])
|
|||
test = optarg;
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
benchmark = true;
|
||||
break;
|
||||
|
||||
case 's': {
|
||||
char *c = strchr(optarg, ',');
|
||||
if (!c)
|
||||
|
@ -669,6 +675,24 @@ int main(int argc, char *argv[])
|
|||
run_bic(cnsl, b, &event, bic_start.value());
|
||||
else if (run_debugger || (bootloader == BL_NONE && test.empty() && tape.empty()))
|
||||
debugger(cnsl, b, &event);
|
||||
else if (benchmark) {
|
||||
// FILL MEMORY
|
||||
memory *m = b->getRAM();
|
||||
for(uint32_t i=0; i<m->get_memory_size(); i++)
|
||||
m->write_byte(i, i);
|
||||
// SET MMU TO ENABLED
|
||||
b->getMMU()->setMMR0_as_is(1); // enable MMU
|
||||
// run for a second
|
||||
b->getCpu()->emulation_start(); // for statistics
|
||||
uint64_t start = get_us();
|
||||
do {
|
||||
b->getCpu()->step();
|
||||
}
|
||||
while(get_us() - start <= 2500000);
|
||||
|
||||
auto stats = b->getCpu()->get_mips_rel_speed({ }, { });
|
||||
cnsl->put_string_lf(format("MIPS: %.2f, relative speed: %.2f%%, instructions executed: %" PRIu64 " in %.2f seconds", std::get<0>(stats), std::get<1>(stats), std::get<2>(stats), std::get<3>(stats) / 1000000.));
|
||||
}
|
||||
else {
|
||||
b->getCpu()->emulation_start(); // for statistics
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue