about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorChristian Krinitsin <mail@krinitsin.com>2025-11-24 11:43:17 +0100
committerChristian Krinitsin <mail@krinitsin.com>2025-11-24 11:43:17 +0100
commit9a6ad70d17d83f8c86deb77efd2e2aec21fe200e (patch)
tree0872c8a1ad4d50a413aa03a98267209af4c67d4e
parent3f77892c8b793aae3b4c0028348f359fabd50bf9 (diff)
downloadfocaccia-9a6ad70d17d83f8c86deb77efd2e2aec21fe200e.tar.gz
focaccia-9a6ad70d17d83f8c86deb77efd2e2aec21fe200e.zip
Add QEMU runtime benchmarks
-rw-r--r--src/focaccia/benchmark/_benchmark.py2
-rwxr-xr-xsrc/focaccia/tools/benchmark_focaccia.py28
2 files changed, 29 insertions, 1 deletions
diff --git a/src/focaccia/benchmark/_benchmark.py b/src/focaccia/benchmark/_benchmark.py
index 60570f7..46e67d0 100644
--- a/src/focaccia/benchmark/_benchmark.py
+++ b/src/focaccia/benchmark/_benchmark.py
@@ -10,7 +10,6 @@ import subprocess
 import time
 
 def main():
-    print("Benchmarking focaccia")
     args = make_argparser().parse_args()
 
     detlog = DeterministicLog(args.deterministic_log)
@@ -30,6 +29,7 @@ def main():
             time.sleep(0.5)
             timer.unpause()
             gdb_server = _qemu_tool.GDBServerStateIterator(f"localhost:{args.port}", detlog)
+            gdb.execute("si")
             gdb.execute("continue")
             qemu_process.wait()
             timer.pause()
diff --git a/src/focaccia/tools/benchmark_focaccia.py b/src/focaccia/tools/benchmark_focaccia.py
index 3b3019e..ad4ce02 100755
--- a/src/focaccia/tools/benchmark_focaccia.py
+++ b/src/focaccia/tools/benchmark_focaccia.py
@@ -58,6 +58,8 @@ def main():
     argparser = make_argparser()
     args = argparser.parse_args()
 
+    logging.basicConfig(level=logging.ERROR)
+
     # Test native tracing
     detlog = DeterministicLog(args.deterministic_log)
     if args.deterministic_log and detlog.base_directory is None:
@@ -79,6 +81,32 @@ def main():
     with open(f"/tmp/benchmark-{args.binary.split('/')[-1]}-symbolic.trace", 'w') as file:
         parser.serialize_transformations(trace, file)
 
+    # Emu exec plain
+    try:
+        timer = Timer("Emulator execution (plain)", iterations=args.iterations)
+        for i in range(timer.iterations):
+            qemu_process = subprocess.run(
+                [f"qemu-{args.guest_arch}", args.binary],
+                stdout=subprocess.DEVNULL,
+                stderr=subprocess.DEVNULL
+            )
+        timer.log_time()
+    except Exception as e:
+        raise Exception(f'Unable to benchmark QEMU: {e}')
+
+    # Emu exec one instruction per block
+    try:
+        timer = Timer("Emulator execution (-one-insn-per-tb)", iterations=args.iterations)
+        for i in range(timer.iterations):
+            qemu_process = subprocess.run(
+                [f"qemu-{args.guest_arch}", "-one-insn-per-tb", args.binary],
+                stdout=subprocess.DEVNULL,
+                stderr=subprocess.DEVNULL
+            )
+        timer.log_time()
+    except Exception as e:
+        raise Exception(f'Unable to benchmark QEMU: {e}')
+
     # Get environment
     env = os.environ.copy()
     # QEMU GDB interface