| 1 |
(** Testing the performance of [pattern]. For not regressing on COQBUG(https://github.com/rocq-prover/rocq/issues/11150) and COQBUG(https://github.com/rocq-prover/rocq/issues/6502) *) |
| 2 |
(* Expected time < 2.00s *) |
| 3 |
(* reference: 0.673s after adjustment *) |
| 4 |
Definition Let_In {A P} (v : A) (f : forall x : A, P x) : P v |
| 5 |
:= let x := v in f x. |
| 6 |
|
| 7 |
Fixpoint big (a : nat) (sz : nat) : nat |
| 8 |
:= match sz with |
| 9 |
| O => a |
| 10 |
| S sz' => Let_In (a * a) (fun a' => big a' sz') |
| 11 |
end. |
| 12 |
|
| 13 |
Ltac do_time n := |
| 14 |
try ( |
| 15 |
once (assert (exists e, e = big 1 n); |
| 16 |
[ lazy -[big]; (*match goal with |- ?G => idtac G end;*) lazy [big]; |
| 17 |
time pattern Nat.mul, S, O, (@Let_In nat (fun _ => nat)) |
| 18 |
| ]); |
| 19 |
fail). |
| 20 |
|
| 21 |
Ltac do_time_to n := |
| 22 |
lazymatch (eval vm_compute in n) with |
| 23 |
| O => idtac |
| 24 |
| ?n' => do_time_to (Nat.div2 n'); idtac n'; do_time n' |
| 25 |
end. |
| 26 |
|
| 27 |
Local Set Warnings "-abstract-large-number". |
| 28 |
|
| 29 |
(* Don't spend lots of time printing *) |
| 30 |
Notation hide := (_ = _). |
| 31 |
|
| 32 |
Goal True. |
| 33 |
Proof. |
| 34 |
(* do_time_to 16384. *) (* should be linear, not quadratic *) |
| 35 |
assert (exists e, e = big 1 16384). |
| 36 |
lazy -[big]; (*match goal with |- ?G => idtac G end;*) lazy [big]. |
| 37 |
Timeout 15 Time pattern Nat.mul, S, O, (@Let_In nat (fun _ => nat)). |
| 38 |
Abort. |