mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
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:
@ -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"
|
||||
|
@ -55,8 +55,10 @@
|
||||
"n" #'+go/test-nested
|
||||
"g" #'go-gen-test-dwim
|
||||
"G" #'go-gen-test-all
|
||||
"e" #'go-gen-test-exported)))
|
||||
|
||||
"e" #'go-gen-test-exported)
|
||||
(:prefix ("tb" . "bench")
|
||||
"s" #'+go/bench-single
|
||||
"a" #'+go/bench-all)))
|
||||
|
||||
(use-package! gorepl-mode
|
||||
:commands gorepl-run-load-current-file)
|
||||
|
Reference in New Issue
Block a user