This PR speeds up some benchmarks when run as tests by lowering their workload. It also stops testing some of the more expensive benchmarks that can't be easily made smaller.
31 lines
1,019 B
Text
31 lines
1,019 B
Text
import Lean
|
|
open Lean
|
|
|
|
def divisorsList (n : Nat) : List Nat :=
|
|
(List.range' 1 n).filter fun d => n % d = 0
|
|
|
|
def mkProblem (n : Nat) : Expr := mkApp (mkConst ``divisorsList) (mkNatLit n)
|
|
|
|
def runProblem (n : Nat) : MetaM Unit := do
|
|
let problem := mkProblem n
|
|
let startTime ← IO.monoNanosNow
|
|
let executed ← Lean.Meta.Tactic.Cbv.cbvEntry problem
|
|
let endTime ← IO.monoNanosNow
|
|
let ms := (endTime - startTime).toFloat / 1000000.0
|
|
match executed with
|
|
| .rfl _ _ => IO.println s!"goal_{n}: {ms} ms"
|
|
| .step _ proof _ _ =>
|
|
let startTime ← IO.monoNanosNow
|
|
Meta.checkWithKernel proof
|
|
let endTime ← IO.monoNanosNow
|
|
let kernelMs := (endTime - startTime).toFloat / 1000000.0
|
|
IO.println s!"cbv: goal_{n}: {ms} ms, kernel: {kernelMs} ms"
|
|
|
|
def runCbvTests : MetaM Unit := do
|
|
IO.println "=== Call-By-Value Tactic Tests ==="
|
|
IO.println ""
|
|
let bench := (← IO.getEnv "TEST_BENCH") == some "1"
|
|
for n in List.range (if bench then 200 else 10) do
|
|
runProblem n
|
|
|
|
#eval runCbvTests
|