Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make std-benchmarks/benchOnly Startup work #8390

Merged
merged 4 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/Benchmarks/src/Main.enso
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import project.Number_Parse
import project.Numeric
import project.Range
import project.Sum
import project.Startup
import project.Startup.Startup
import project.Runtime.Panics_And_Errors
from Standard.Base.Runtime import Debug

Expand Down
52 changes: 0 additions & 52 deletions test/Benchmarks/src/Startup.enso

This file was deleted.

1 change: 1 addition & 0 deletions test/Benchmarks/src/Startup/Empty_World.enso
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main = "Hello World"
3 changes: 3 additions & 0 deletions test/Benchmarks/src/Startup/Hello_World.enso
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from Standard.Base import IO

main = IO.println "Hello World"
70 changes: 70 additions & 0 deletions test/Benchmarks/src/Startup/Startup.enso
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from Standard.Base import all

from Standard.Test import Bench

polyglot java import java.lang.System as Java_System
polyglot java import java.io.File as Java_File

type Data
Value ~enso_bin:File ~empty_world:File ~hello_world:File

bench_empty self =
self.startup [ "--run", self.empty_world.to_text ]

bench_hello self =
self.startup [ "--run", self.hello_world.to_text ]

startup self args =
exe = self.enso_bin
result = Process.run exe.path args
case result.exit_code of
Exit_Code.Failure code ->
IO.println "Exit code: "+code.to_text
IO.println result.stdout
IO.println result.stderr
Panic.throw "Exit code: "+code.to_text
Exit_Code.Success ->
if result.stdout.contains "Hello World" then Nothing else
msg = "Execution should contain 'Hello World', but:\n====\n" + result.stdout + '\n' + result.stderr + "\n===="
IO.println msg
Panic.throw msg

collect_benches = Bench.build builder->
options = Bench.options . set_warmup (Bench.phase_conf 2 5) . set_measure (Bench.phase_conf 3 5)


data =
Data.Value enso_bin (find_sibling "Empty_World.enso") (find_sibling "Hello_World.enso")

builder.group "Startup" options group_builder->
group_builder.specify "empty_startup" data.bench_empty
group_builder.specify "hello_world_startup" data.bench_hello

find_sibling name =
f = enso_project.root / "src" / "Startup" / name
if f.is_regular_file.not then Panic.throw "Cannot find "+f.to_text
f

enso_bin =
find_prefix dir prefix =
vec = dir.list name_filter=prefix+"*"
if vec.length == 1 then vec.at 0 else
msg = "Cannot find " + prefix + "* in" + dir.to_text + "\n"
err = dir.list.fold msg t-> f->
t + f.to_text + "\n"
Panic.throw err

project_root = File.new enso_project.root.to_text
repository_root = project_root . parent . parent
built_distribution = find_prefix repository_root "built-distribution"
enso_engine = find_prefix built_distribution "enso-engine-"
enso = find_prefix enso_engine "enso-"
bin = find_prefix enso "bin"

exe = File.new bin / if Platform.os == Platform.OS.Windows then "enso.bat" else "enso"

if exe.is_regular_file.not then Panic.throw "Cannot find "+exe.to_text

exe

main = collect_benches . run_main
Loading