|
@@ -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;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(LOG_SERIAL) process.stdout.write(chr);
|
|
|
|
|
|
- serial_text += c;
|
|
|
+ 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));
|
|
|
+ }
|
|
|
}
|
|
|
});
|