mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-18 03:55:31 +00:00
Use shared profiling info for encode, write and hexl operations.
This commit is contained in:
parent
d579b7b3e2
commit
305d8022c4
20
vlf-occur.el
20
vlf-occur.el
@ -153,8 +153,6 @@ Prematurely ending indexing will still show what's found so far."
|
||||
(batch-size vlf-batch-size)
|
||||
(is-hexl (derived-mode-p 'hexl-mode))
|
||||
(insert-bps vlf-tune-insert-bps)
|
||||
(encode-bps vlf-tune-encode-bps)
|
||||
(hexl-bps vlf-tune-hexl-bps)
|
||||
(insert-raw-bps vlf-tune-insert-raw-bps))
|
||||
(with-temp-buffer
|
||||
(setq buffer-file-name file
|
||||
@ -164,11 +162,9 @@ Prematurely ending indexing will still show what's found so far."
|
||||
(set-buffer-modified-p nil)
|
||||
(set (make-local-variable 'vlf-batch-size) batch-size)
|
||||
(when vlf-tune-enabled
|
||||
(setq vlf-tune-insert-bps insert-bps
|
||||
vlf-tune-encode-bps encode-bps)
|
||||
(setq vlf-tune-insert-bps insert-bps)
|
||||
(if is-hexl
|
||||
(progn (setq vlf-tune-hexl-bps hexl-bps
|
||||
vlf-tune-insert-raw-bps insert-raw-bps)
|
||||
(progn (setq vlf-tune-insert-raw-bps insert-raw-bps)
|
||||
(vlf-tune-batch '(:hexl :raw) t))
|
||||
(vlf-tune-batch '(:insert :encode) t)))
|
||||
(vlf-mode 1)
|
||||
@ -176,17 +172,13 @@ Prematurely ending indexing will still show what's found so far."
|
||||
(goto-char (point-min))
|
||||
(vlf-build-occur regexp vlf-buffer)
|
||||
(when vlf-tune-enabled
|
||||
(setq insert-bps vlf-tune-insert-bps
|
||||
encode-bps vlf-tune-encode-bps)
|
||||
(setq insert-bps vlf-tune-insert-bps)
|
||||
(if is-hexl
|
||||
(setq hexl-bps vlf-tune-hexl-bps
|
||||
insert-raw-bps vlf-tune-insert-raw-bps))))
|
||||
(setq insert-raw-bps vlf-tune-insert-raw-bps))))
|
||||
(when vlf-tune-enabled ;merge back tune measurements
|
||||
(setq vlf-tune-insert-bps insert-bps
|
||||
vlf-tune-encode-bps encode-bps)
|
||||
(setq vlf-tune-insert-bps insert-bps)
|
||||
(if is-hexl
|
||||
(setq vlf-tune-hexl-bps hexl-bps
|
||||
vlf-tune-insert-raw-bps insert-raw-bps)))))
|
||||
(setq vlf-tune-insert-raw-bps insert-raw-bps)))))
|
||||
|
||||
(defun vlf-occur (regexp)
|
||||
"Make whole file occur style index for REGEXP.
|
||||
|
29
vlf-tune.el
29
vlf-tune.el
@ -60,11 +60,13 @@ but don't change batch size. If t, measure and change."
|
||||
(if ram-size
|
||||
(/ ram-size 20)
|
||||
large-file-warning-threshold))
|
||||
"Maximum batch size in bytes when auto tuning."
|
||||
"Maximum batch size in bytes when auto tuning.
|
||||
Avoid increasing this after opening file with VLF."
|
||||
:group 'vlf :type 'integer)
|
||||
|
||||
(defcustom vlf-tune-step (/ vlf-tune-max 10000)
|
||||
"Step used for tuning in bytes."
|
||||
"Step used for tuning in bytes.
|
||||
Avoid decreasing this after opening file with VLF."
|
||||
:group 'vlf :type 'integer)
|
||||
|
||||
(defcustom vlf-tune-load-time 1.0
|
||||
@ -83,23 +85,15 @@ but don't change batch size. If t, measure and change."
|
||||
|
||||
(defvar vlf-tune-encode-bps nil
|
||||
"Vector of bytes per second encode measurements.")
|
||||
(make-variable-buffer-local 'vlf-tune-encode-bps)
|
||||
(put 'vlf-tune-encode-bps 'permanent-local t)
|
||||
|
||||
(defvar vlf-tune-write-bps nil
|
||||
"Vector of bytes per second write measurements.")
|
||||
(make-variable-buffer-local 'vlf-tune-write-bps)
|
||||
(put 'vlf-tune-write-bps 'permanent-local t)
|
||||
|
||||
(defvar vlf-tune-hexl-bps nil
|
||||
"Vector of bytes per second hexlify measurements.")
|
||||
(make-variable-buffer-local 'vlf-tune-hexl-bps)
|
||||
(put 'vlf-tune-hexl-bps 'permanent-local t)
|
||||
|
||||
(defvar vlf-tune-dehexlify-bps nil
|
||||
"Vector of bytes per second dehexlify measurements.")
|
||||
(make-variable-buffer-local 'vlf-tune-dehexlify-bps)
|
||||
(put 'vlf-tune-dehexlify-bps 'permanent-local t)
|
||||
|
||||
(defun vlf-tune-closest-index (size)
|
||||
"Get closest measurement index corresponding to SIZE."
|
||||
@ -114,8 +108,6 @@ but don't change batch size. If t, measure and change."
|
||||
|
||||
(defun vlf-tune-initialize-measurement ()
|
||||
"Initialize measurement vector."
|
||||
(make-local-variable 'vlf-tune-max)
|
||||
(make-local-variable 'vlf-tune-step)
|
||||
(make-vector (1- (/ vlf-tune-max vlf-tune-step)) nil))
|
||||
|
||||
(defmacro vlf-tune-add-measurement (vec size time)
|
||||
@ -168,15 +160,16 @@ FILE if given is filename to be used, otherwise `buffer-file-name'."
|
||||
(cdr result) (car result))
|
||||
(cdr result)))
|
||||
|
||||
(defun vlf-tune-write (start end append visit size &optional file)
|
||||
(defun vlf-tune-write (start end append visit size &optional file-name)
|
||||
"Save buffer and save time it takes.
|
||||
START, END, APPEND, VISIT have same meaning as in `write-region'.
|
||||
SIZE is number of bytes that are saved.
|
||||
FILE if given is filename to be used, otherwise `buffer-file-name'."
|
||||
(let ((time (car (vlf-time (write-region start end
|
||||
(or file buffer-file-name)
|
||||
append visit)))))
|
||||
(vlf-tune-add-measurement vlf-tune-write-bps size time)))
|
||||
FILE-NAME if given is to be used instead of `buffer-file-name'."
|
||||
(let* ((file (or file-name buffer-file-name))
|
||||
(time (car (vlf-time (write-region start end file append
|
||||
visit)))))
|
||||
(or (file-remote-p file) ;writing to remote files can include network copying
|
||||
(vlf-tune-add-measurement vlf-tune-write-bps size time))))
|
||||
|
||||
(defun vlf-tune-hexlify ()
|
||||
"Activate `hexl-mode' and save time it takes."
|
||||
|
Loading…
Reference in New Issue
Block a user