From f48cd0dd5ec18df9c0fcb74747610fb6e4e564a6 Mon Sep 17 00:00:00 2001
From: Torben Ewert
Date: Fri, 10 Jul 2026 16:07:54 +0200
Subject: [PATCH] chore: update benchmark to do performance testing on vm
---
.gitignore | 4 +
benchmark/benchmark.ml | 26 +-
benchmark/data/Benchmark.pi | 1403 ++++++++++++++++++-----------------
3 files changed, 725 insertions(+), 708 deletions(-)
diff --git a/.gitignore b/.gitignore
index eb312bf..14940d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,7 @@ js/**/*.bc.js
node_modules
.DS_Store
+
+perf.data
+perf.data.old
+perf.sh
\ No newline at end of file
diff --git a/benchmark/benchmark.ml b/benchmark/benchmark.ml
index 2ce83bf..057f8e6 100644
--- a/benchmark/benchmark.ml
+++ b/benchmark/benchmark.ml
@@ -1,7 +1,7 @@
[@@@warning "-unused-value-declaration"]
[@@@warning "-unused-constructor"]
-let iterations = 1000
+let iterations = 1
module Time : sig
type t
@@ -204,23 +204,23 @@ module Benchmarks : sig
end = struct
type action =
| Parse
- (* | Compile
+ | Compile
| Deserialize
- | Vm of string *)
+ | Vm of string
| Interp of string
let string_of_action = function
| Parse -> "[PARSER]"
- (* | Compile -> "[COMPILER]"
- | Deserialize -> "[DESERIALIZATION]"
- | Vm s -> "[VM] " ^ s *)
+ | Compile -> "[COMPILER]"
+ | Deserialize -> "[DESERIALIZATION]"
+ | Vm s -> "[VM] " ^ s
| Interp s -> "[INTERPRETER] " ^ s
;;
let benchmark filename action =
let src = Pinc_lang.Source.of_file filename in
- let ast = Pinc_lang.Parser.get_ast [ src ] in
- (* let bytecode = Pinc_lang.Compiler.compile ast in *)
+ let ast = Pinc_lang.Parser.get_ast ~include_stdlib:false [ src ] in
+ let bytecode = Pinc_lang.Compiler.compile ast in
let benchmarkFn =
match action with
| Parse -> fun _ -> ignore @@ Sys.opaque_identity (Pinc_lang.Parser.get_ast [ src ])
@@ -232,10 +232,10 @@ end = struct
~tag_data_provider:Pinc_lang.Helpers.noop_data_provider
~root
ast)
- (* | Compile -> fun _ -> ignore @@ Sys.opaque_identity (Pinc_lang.Compiler.compile ast)
+ | Compile -> fun _ -> ignore @@ Sys.opaque_identity (Pinc_lang.Compiler.compile ast)
| Deserialize ->
fun _ -> ignore @@ Sys.opaque_identity (Pinc_lang.Bytecode.deserialize bytecode)
- | Vm _root -> fun _ -> ignore @@ Sys.opaque_identity (Pinc_lang.Vm.eval bytecode) *)
+ | Vm _root -> fun _ -> ignore @@ Sys.opaque_identity (Pinc_lang.Vm.eval bytecode)
in
let name = filename ^ " " ^ string_of_action action in
let b = Benchmark.make ~name ~f:benchmarkFn () in
@@ -245,9 +245,9 @@ end = struct
let run () =
benchmark "./benchmark/data/Benchmark.pi" Parse;
- (* benchmark "./benchmark/data/Benchmark.pi" Compile; *)
- (* benchmark "./benchmark/data/Benchmark.pi" Deserialize; *)
- (* benchmark "./benchmark/data/Benchmark.pi" (Vm "Benchmark"); *)
+ benchmark "./benchmark/data/Benchmark.pi" Compile;
+ benchmark "./benchmark/data/Benchmark.pi" Deserialize;
+ benchmark "./benchmark/data/Benchmark.pi" (Vm "Benchmark");
benchmark "./benchmark/data/Benchmark.pi" (Interp "Benchmark")
;;
end
diff --git a/benchmark/data/Benchmark.pi b/benchmark/data/Benchmark.pi
index fa96d4b..0ff7430 100644
--- a/benchmark/data/Benchmark.pi
+++ b/benchmark/data/Benchmark.pi
@@ -1,801 +1,814 @@
-page Benchmark {
- #SetContext(
- key: "settings",
- value: {
- logo: "/public/images/logo.svg",
- contact: {
- title: "aute veniam",
- address: "Lorem Ipsumstreet 22",
- phone: "01234567890",
- email: "lorem@ipsum.com",
- },
- footerLinks: [
- {
- url: "#0",
- title: "sunt minim",
- },
- {
- url: "#0",
- title: "culpa incididunt",
- },
- {
- url: "#0",
- title: "deserunt",
- },
- {
- url: "#0",
- title: "tempor veniam",
+/*
+ page Benchmark {
+ #SetContext(
+ key: "settings",
+ value: {
+ logo: "/public/images/logo.svg",
+ contact: {
+ title: "aute veniam",
+ address: "Lorem Ipsumstreet 22",
+ phone: "01234567890",
+ email: "lorem@ipsum.com",
},
- ],
- },
- );
-
- #SetContext(
- key: "projects",
- value: [
- {
- jobs: ["", "", "", ""],
- title: "",
- intro: "",
- url: "",
- image: "",
- },
- {
- jobs: ["", "", "", ""],
- title: "",
- intro: "",
- url: "",
- image: "",
- },
- {
- jobs: ["", "", "", ""],
- title: "",
- intro: "",
- url: "",
- image: "",
- },
- {
- jobs: ["", "", "", ""],
- title: "",
- intro: "",
- url: "",
- image: "",
- },
- {
- jobs: ["", "", "", ""],
- title: "",
- intro: "",
- url: "",
- image: "",
- },
- {
- jobs: ["", "", "", ""],
- title: "",
- intro: "",
- url: "",
- image: "",
- },
- {
- jobs: ["", "", "", ""],
- title: "",
- intro: "",
- url: "",
- image: "",
- },
- {
- jobs: ["", "", "", ""],
- title: "",
- intro: "",
- url: "",
- image: "",
- },
- {
- jobs: ["", "", "", ""],
- title: "",
- intro: "",
- url: "",
- image: "",
- },
- {
- jobs: ["", "", "", ""],
- title: "",
- intro: "",
- url: "",
- image: "",
- },
- {
- jobs: ["", "", "", ""],
- title: "",
- intro: "",
- url: "",
- image: "",
- },
- ],
- );
-
-
-
-
-
-
-
-
-
+ ],
+ },
+ );
-
+ #SetContext(
+ key: "projects",
+ value: [
+ {
+ jobs: ["", "", "", ""],
+ title: "",
+ intro: "",
+ url: "",
+ image: "",
+ },
+ {
+ jobs: ["", "", "", ""],
+ title: "",
+ intro: "",
+ url: "",
+ image: "",
+ },
+ {
+ jobs: ["", "", "", ""],
+ title: "",
+ intro: "",
+ url: "",
+ image: "",
+ },
+ {
+ jobs: ["", "", "", ""],
+ title: "",
+ intro: "",
+ url: "",
+ image: "",
+ },
+ {
+ jobs: ["", "", "", ""],
+ title: "",
+ intro: "",
+ url: "",
+ image: "",
+ },
+ {
+ jobs: ["", "", "", ""],
+ title: "",
+ intro: "",
+ url: "",
+ image: "",
+ },
+ {
+ jobs: ["", "", "", ""],
+ title: "",
+ intro: "",
+ url: "",
+ image: "",
+ },
+ {
+ jobs: ["", "", "", ""],
+ title: "",
+ intro: "",
+ url: "",
+ image: "",
+ },
+ {
+ jobs: ["", "", "", ""],
+ title: "",
+ intro: "",
+ url: "",
+ image: "",
+ },
+ {
+ jobs: ["", "", "", ""],
+ title: "",
+ intro: "",
+ url: "",
+ image: "",
+ },
+ {
+ jobs: ["", "", "", ""],
+ title: "",
+ intro: "",
+ url: "",
+ image: "",
+ },
+ ],
+ );
-
-
+
-
+
+
+
+
+
-
-
-
-}
-page Home {
- let title = #String;
- let content = #Slot(key: "");
-
- <>
-
-
-
-
-
- {content}
-
-
-
-
- >
-}
-
-component Footer {
- #Portal(key: "stylesheets", push: );
+
- let settings = #GetContext(key: "settings");
+
+
+
+
- let contact = settings.contact;
- let links = settings.footerLinks;
+
+ }
- let email = contact.email;
+ page Home {
+ let title = #String;
+ let content = #Slot(key: "");
+
+ <>
+
+
+
+
+ {content}
+
+
+
+
+ >
+ }
-