add benchmark bindings (,tbs and ,tba)

go supports running benchmarks much similar to running tests,
the new key bindings will run single or all benchmark
This commit is contained in:
Remco Verhoef 2020-02-09 10:58:49 +01:00
parent 01aadd8900
commit 7fe392d946
No known key found for this signature in database
GPG key ID: FB9262FA69FC5392
2 changed files with 19 additions and 2 deletions

View file

@ -41,6 +41,21 @@
(+go--run-tests (concat "-run" "='" (match-string-no-properties 2) "'")))
(error "Must be in a _test.go file")))
;;;###autoload
(defun +go/bench-all ()
(interactive)
(+go--run-tests "-test.run=NONE -test.bench=\".*\""))
;;;###autoload
(defun +go/bench-single ()
(interactive)
(if (string-match "_test\\.go" buffer-file-name)
(save-excursion
(re-search-backward "^func[ ]+\\(([[:alnum:]]*?[ ]?[*]?[[:alnum:]]+)[ ]+\\)?\\(Benchmark[[:alnum:]_]+\\)(.*)")
(+go--run-tests (concat "-test.run=NONE -test.bench" "='" (match-string-no-properties 2) "'")))
(error "Must be in a _test.go file")))
;;;###autoload
(defun +go/play-buffer-or-region (&optional beg end)
"TODO"