benchmark script improvements

This commit is contained in:
Fabian 2020-12-31 19:14:33 -06:00
parent f8206859ca
commit 8638c6abaf
2 changed files with 51 additions and 10 deletions

View file

@ -1,12 +1,15 @@
#!/usr/bin/env node
"use strict";
const BENCH_COLLECT_STATS = +process.env.BENCH_COLLECT_STATS;
const V86 = require(`../../build/${BENCH_COLLECT_STATS ? "libv86-debug" : "libv86"}.js`).V86;
const print_stats = require("../../build/libv86.js").print_stats;
const path = require("path");
var V86 = require("../../build/libv86.js").V86;
const V86_ROOT = path.join(__dirname, "../..");
var emulator = new V86({
const emulator = new V86({
bios: { url: path.join(V86_ROOT, "/bios/seabios.bin") },
vga_bios: { url: path.join(V86_ROOT, "/bios/vgabios.bin") },
autostart: true,
@ -21,12 +24,32 @@ var emulator = new V86({
baseurl: path.join(V86_ROOT, "/images/arch/"),
},
screen_dummy: true,
log_level: 0,
});
emulator.bus.register("emulator-started", function()
{
let exclude_tests = [];
if(process.argv.length > 2)
{
exclude_tests = [
"DONUMSORT",
"DOSTRINGSORT",
"DOBITFIELD",
"DOEMF",
"DOFOUR",
"DOASSIGN",
"DOIDEA",
"DOHUFF",
"DONNET",
"DOLU",
].filter(name => !process.argv.includes(name));
}
setTimeout(() => {
emulator.serial0_send("cd nbench && ./nbench\n");
const set = exclude_tests.map(name => `echo ${name}=0 >> CMD && `).join("");
emulator.serial0_send(`cd nbench && touch CMD && ${set} ./nbench -cCMD\n`);
}, 1000);
});
@ -52,5 +75,11 @@ emulator.add_listener("serial0-output-char", function(chr)
if(line === "* Trademarks are property of their respective holder.")
{
emulator.stop();
if(BENCH_COLLECT_STATS)
{
const cpu = emulator.v86.cpu;
console.log(print_stats.stats_to_string(cpu));
}
}
});

View file

@ -1,7 +1,9 @@
#!/usr/bin/env node
"use strict";
const V86 = require("../../build/libv86.js").V86;
const BENCH_COLLECT_STATS = +process.env.BENCH_COLLECT_STATS;
const V86 = require(`../../build/${BENCH_COLLECT_STATS ? "libv86-debug" : "libv86"}.js`).V86;
const print_stats = require("../../build/libv86.js").print_stats;
const fs = require("fs");
const path = require("path");
@ -9,7 +11,7 @@ const V86_ROOT = path.join(__dirname, "../..");
const LOG_SERIAL = true;
if(false)
if(true)
{
var emulator = new V86({
bios: { url: __dirname + "/../../bios/seabios.bin" },
@ -17,6 +19,7 @@ if(false)
cdrom: { url: __dirname + "/../../images/linux3.iso" },
autostart: true,
memory_size: 32 * 1024 * 1024,
log_level: 0,
});
}
else
@ -37,6 +40,7 @@ else
baseurl: path.join(V86_ROOT, "/images/arch/"),
},
screen_dummy: true,
log_level: 0,
});
}
@ -49,11 +53,16 @@ emulator.bus.register("emulator-started", function()
var serial_text = "";
var start_time;
emulator.add_listener("serial0-output-char", function(c)
emulator.add_listener("serial0-output-char", function(chr)
{
if(LOG_SERIAL) process.stdout.write(c);
if(chr < " " && chr !== "\n" && chr !== "\t" || chr > "~")
{
return;
}
serial_text += c;
if(LOG_SERIAL) process.stdout.write(chr);
serial_text += chr;
if(serial_text.endsWith("~% ") || serial_text.endsWith("root@localhost:~# "))
{
@ -62,7 +71,10 @@ emulator.add_listener("serial0-output-char", function(c)
console.log("Done in %dms", elapsed);
emulator.stop();
const cpu = emulator.v86.cpu;
console.log(print_stats.stats_to_string(cpu));
if(BENCH_COLLECT_STATS)
{
const cpu = emulator.v86.cpu;
console.log(print_stats.stats_to_string(cpu));
}
}
});