diff --git a/src/runbenchmark.jl b/src/runbenchmark.jl index 0bc63bd..de8bec3 100644 --- a/src/runbenchmark.jl +++ b/src/runbenchmark.jl @@ -68,8 +68,7 @@ defaulttunefile(pkg) = saveresults=true, tunefile=defaulttunefile(pkg), retune=false, - promptsave=true, - promptoverwrite=true) + overwrite=true) **Arguments**: @@ -82,11 +81,9 @@ defaulttunefile(pkg) = * `require` is the REQUIRE file containing dependencies needed for the benchmark. Defaults to `PKG/benchmark/REQUIRE`. * `resultsdir` the directory where to file away results. Defaults to `PKG/benchmark/.results`. Provided the repository is not dirty, results generated will be saved in this directory in a file named `.jld`. And can be used later by functions such as `judge`. If you choose to, you can save the results manually using `writeresults(file, results)` where `results` is the return value of `benchmarkpkg` function. It can be read back with `readresults(file)`. * `saveresults` if set to false, results will not be saved in `resultsdir`. -* `promptsave` if set to false, you will prompted to confirm before saving the results. * `tunefile` file to use for tuning benchmarks, will be created if doesn't exist. Defaults to `PKG/benchmark/.tune.jld` * `retune` force a re-tune, saving results to the tune file -* `promptsave` if set to false, you will prompted to confirm before saving the results. -* `promptoverwrite` if set to false, will not asked to confirm before overwriting previously saved results for a commit. +* `overwrite` overwrites the result file if it already exists **Returns:** @@ -110,9 +107,11 @@ function benchmarkpkg(pkg, ref=nothing; tunefile=defaulttunefile(pkg), retune=false, saveresults=true, - promptsave=true, - promptoverwrite=true, - custom_loadpath="" #= used in tests =#) + overwrite=true, + custom_loadpath="", #= used in tests =# + promptsave=nothing #= deprecated =#) + + promptsave != nothing && Base.warn_once("the `promptsave` keyword is deprecated and will be removed.") function do_benchmark() !isfile(script) && error("Benchmark script $script not found") @@ -129,16 +128,25 @@ function benchmarkpkg(pkg, ref=nothing; if !dirty if saveresults - tosave = if promptsave + tosave = true + if promptsave == true print("File results of this run? (commit=$(sha[1:6]), resultsdir=$resultsdir) (Y/n) ") - response = readline() |> strip - response == "" || lowercase(response) == "y" - else true end + response = string(readline()) + tosave = if response == "" || lowercase(response) == "y" + true + else + false + end + end if tosave !isdir(resultsdir) && mkpath(resultsdir) resfile = joinpath(resultsdir, sha*".jld") - writeresults(resfile, res) - info("Results of the benchmark were written to $resfile") + if !isfile(resfile) || overwrite == true + writeresults(resfile, res) + info("Results of the benchmark were written to $resfile") + else + info("Found existing results, no output written") + end end end else diff --git a/test/runtests.jl b/test/runtests.jl index 679a14d..b40c25e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -77,12 +77,12 @@ temp_pkg_dir(;tmp_dir = tmp_dir) do # Test we are on a branch and run benchmark on a commit that we end up back on the branch LibGit2.branch!(repo, "PR") LibGit2.branch!(repo, "master") - PkgBenchmark.benchmarkpkg(TEST_PACKAGE_NAME, "PR"; custom_loadpath=old_pkgdir, promptsave=false) + PkgBenchmark.benchmarkpkg(TEST_PACKAGE_NAME, "PR"; custom_loadpath=old_pkgdir) @test LibGit2.branch(repo) == "master" # Test we are on a commit and run benchmark on another commit and end up on the commit LibGit2.checkout!(repo, string(commit_master)) - PkgBenchmark.benchmarkpkg(TEST_PACKAGE_NAME, "PR"; custom_loadpath=old_pkgdir, promptsave=false) + PkgBenchmark.benchmarkpkg(TEST_PACKAGE_NAME, "PR"; custom_loadpath=old_pkgdir) @test LibGit2.revparseid(repo, "HEAD") == commit_master end @@ -105,7 +105,7 @@ temp_pkg_dir(;tmp_dir = tmp_dir) do commitid = LibGit2.commit(repo, "commiting full benchmarks and REQUIRE"; author=test_sig, committer=test_sig) resfile = joinpath(tmp, "$(string(commitid)).jld") @test !LibGit2.isdirty(repo) - results = PkgBenchmark.benchmarkpkg(TEST_PACKAGE_NAME, "HEAD"; custom_loadpath=old_pkgdir, promptsave=false, resultsdir=tmp) + results = PkgBenchmark.benchmarkpkg(TEST_PACKAGE_NAME, "HEAD"; custom_loadpath=old_pkgdir, resultsdir=tmp) test_structure(results) @test isfile(resfile) @test PkgBenchmark.readresults(resfile) == results @@ -116,7 +116,7 @@ temp_pkg_dir(;tmp_dir = tmp_dir) do LibGit2.commit(repo, "dummy commit"; author=test_sig, committer=test_sig) @testset "withresults" begin - PkgBenchmark.withresults(TEST_PACKAGE_NAME, ["HEAD~", "HEAD"], custom_loadpath=old_pkgdir, promptsave=false) do res + PkgBenchmark.withresults(TEST_PACKAGE_NAME, ["HEAD~", "HEAD"], custom_loadpath=old_pkgdir) do res @test length(res) == 2 a, b = res test_structure(a) @@ -124,4 +124,4 @@ temp_pkg_dir(;tmp_dir = tmp_dir) do test_structure(judge(minimum(a), minimum(b))) end end -end \ No newline at end of file +end