[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elisp-benchmarks b5881ec 4/6: * benchmarks/pcase.el: Ad
From: |
Andrea Corallo |
Subject: |
[elpa] externals/elisp-benchmarks b5881ec 4/6: * benchmarks/pcase.el: Add new u-benchmark. |
Date: |
Tue, 9 Jun 2020 15:44:38 -0400 (EDT) |
branch: externals/elisp-benchmarks
commit b5881ec4eae8de3fe332626ec09d1c47b38e5712
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>
* benchmarks/pcase.el: Add new u-benchmark.
---
benchmarks/pcase.el | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/benchmarks/pcase.el b/benchmarks/pcase.el
new file mode 100644
index 0000000..22d9407
--- /dev/null
+++ b/benchmarks/pcase.el
@@ -0,0 +1,50 @@
+;; -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2020 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Apply a simple pattern match defined with pcase on the element of a list.
+
+(require 'cl-lib)
+
+(defvar elb-pcase-len 5000)
+(defvar elb-pcase-list (cl-loop repeat elb-pcase-len
+ collect (cl-case (random 3)
+ (0 '(a b))
+ (1 '(a))
+ (2 (random 10)))))
+
+(defsubst foo (x)
+ (1+ x))
+
+(defsubst bar (x)
+ (* x x))
+
+(defun elb-pcase (l)
+ (cl-loop for x in l
+ counting (pcase x
+ (`(a b) 1)
+ (`(a) 2)
+ (_ (foo (bar x))))))
+
+(defun elb-pcase-entry ()
+ (cl-loop repeat 20000
+ do (elb-pcase elb-pcase-list)))
+
+(provide 'elb-pcase)
- [elpa] externals/elisp-benchmarks updated (fe6aa3e -> 08a960d), Andrea Corallo, 2020/06/09
- [elpa] externals/elisp-benchmarks a0e3daf 1/6: * benchmarks/flet.el: Add new u-benchmark., Andrea Corallo, 2020/06/09
- [elpa] externals/elisp-benchmarks f230f42 3/6: * elisp-benchmarks.el (elisp-benchmarks-run): Minor, better regexp., Andrea Corallo, 2020/06/09
- [elpa] externals/elisp-benchmarks b5881ec 4/6: * benchmarks/pcase.el: Add new u-benchmark.,
Andrea Corallo <=
- [elpa] externals/elisp-benchmarks 2f653a2 2/6: * .gitignore: Ignore eln files and eln compile folder., Andrea Corallo, 2020/06/09
- [elpa] externals/elisp-benchmarks e26947a 5/6: * benchmarks/map-closure.el: Add new u-benchmark., Andrea Corallo, 2020/06/09
- [elpa] externals/elisp-benchmarks 08a960d 6/6: ; * elisp-benchmarks.el: Tag new version and update copyright., Andrea Corallo, 2020/06/09